Xunit not working with Visual Studio Team Services Build VNext

After a few blogs that describe how to get xUnit working with Team Services Build vNext:

None of them worked for me. Studying build logs, I get the following warnings for each of my test builds.

-------------------- Warning: [xUnit.net 00:00:00.1644156] Exception discovering tests from CHO.SAM.Business.Test: System.BadImageFormatException: Could not load file or assembly 'c:\_Work\473cef3c\CHO\CHO.ALL\Tests\CHO.SAM.Business.Test\CHO.SAM.Business.Test\bin\Debug\xunit.execution.desktop.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. -------------------- 

Has anyone seen this before? and if you figured out a solution?

My thoughts; My test projects compiled using the .NET Framework 4.6, I was wondering if this could cause a problem? If this is the case, I will have to switch to nUnit or something else, since I do not think it is right to change compilation only to use a single test environment.

+2
source share
5 answers
  • Add "/ Framework: Framework45" to the "Advanced / Other console options" (to run under .NET 4.5)
    or
  • Add "/ Framework: Framework40" to the "Advanced / Other console options" (to run under .NET 4.0)
    or
  • Change the "Extended / VSTest version" to "Visual Studio 2013" (to run under .NET 3.5).
+2
source

This error is usually caused by x64 compilation running on the x86 test server or vice versa. Check the configuration of the solution assembly that is running.

+1
source

I had the same problem. Adding a UI test did not fix it for me. I found two alternatives that work:

  • use .net 4.5

    OR

  • Set advanced task parameters for VSTest to use 2013 instead of 2015.

Hope this will be fixed soon.

+1
source

In the end, I added a Visual Studio Coded UI testing project and deleted all the content (class), it is empty!

I guess he added a link or something that the build server considered necessary.

Now I have found that my unit tests are detected, run and with code coverage.

Wierd!

It works, but I don’t know why ...

0
source

I ran into this problem when using the .Net Core class library to run xUnit tests with the .Net Core Web Project (.NET Framework). I decided to change the default processor to run the test on X64 in VS2015 with:

Menu bar β†’ Test β†’ Test settings β†’ Default processor architecture β†’ X64

This solution was posted by @RehanSaeed here https://github.com/dotnet/cli/issues/3103

0
source

Source: https://habr.com/ru/post/983337/


All Articles