xUnit.NET: Running tests written in Visual Studio 2010
Join the DZone community and get the full member experience.
Join For FreeA problem I ran into when attempting to run my tests against 'xunit.console.exe' is that xUnit.NET is linked to run against version 2.0 of the CLR and right now you can't actually change the 'targetframework' for a project compiled in Visual Studio 2010.
> xunit.console.exe ..\..\TwitterTests\bin\Debug\TwitterTests.dll
System.BadImageFormatException: Could not load file or assembly 'C:\Playbox\FSharpPlayground\Twitter\TwitterTests\bin\Debug\TwitterTests.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'C:\Playbox\FSharpPlayground\Twitter\TwitterTests\bin\Debug\TwitterTests.dll'
at System.Reflection.AssemblyName.nGetFileInformation(String s)
at System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile)
at Xunit.Sdk.Executor..ctor(String assemblyFilename)
at Xunit.ExecutorWrapper.RethrowWithNoStackTraceLoss(Exception ex)
at Xunit.ExecutorWrapper.CreateObject(String typeName, Object[] args)
at Xunit.ExecutorWrapper..ctor(String assemblyFilename, String configFilename, Boolean shadowCopy)
at Xunit.ConsoleClient.Program.Main(String[] args)
I wasn't really sure how to fix this but luckily Dave pointed out that the way to do this is to add a 'requiredRunTime' tag in the 'startup' section of the configuration file (xunit.console.exe.config):
<configuration>
...
<startup>
<requiredRuntime version="v4.0.20506" safemode="true"/>
</startup>
...
</configuration>
And all is good:
> xunit.console.exe ..\..\TwitterTests\bin\Debug\TwitterTests.dll
xUnit.net console runner (xunit.dll version 1.4.9.1416)
Test assembly: C:\Playbox\FSharpPlayground\Twitter\TwitterTests\bin\Debug\TwitterTests.dll
........
Total tests: 8, Failures: 0, Skipped: 0, Time: 0.231 seconds
Published at DZone with permission of Mark Needham, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Merge GraphQL Schemas Using Apollo Server and Koa
-
13 Impressive Ways To Improve the Developer’s Experience by Using AI
-
Explainable AI: Making the Black Box Transparent
-
Managing Data Residency, the Demo
Comments