Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xUnit 1.9.2 and .Net 4.0

I am trying to implement xUnit for C# testing but am running into a strange error.

I can run the unit tests in VisualStudio (2013) but when I try to run the same tests using the GUI or console I get the error:

xUnit.net console test runner (32-bit .NET 2.0.50727.5472)
Copyright (C) 2013 Outercurve Foundation.

Could not load file or assembly '[...]' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded
runtime and cannot be loaded.

My project is using .net 4.0 and it appears xUnit is using 2.0.

I found a couple of posts here and here, among others, saying you can edit the config file but this didn't work for me. Both of these posts are a couple years old and they don't even agree with each other. One says the entry should be 'supportedRuntime' while the other is 'requiredRuntime'. Neither of them work for me, however.

I also thought about downloading the source and compiling it using 4.0 but according to the web site it requires VS 2010.

Running the tests within the IDE is great but I also need to use the console runner in order to implement automated tests on our build machine. Is there a way to get this to work? Or is xUnit no longer being maintained?

I also found another post where the issue was supposedly fixed back in 2010. Maybe this is a regression failure?

like image 723
Mark Wagoner Avatar asked Feb 13 '23 22:02

Mark Wagoner


1 Answers

Thanks, Mark. But I have since found there is a separate xunit.console.clr4.exe executable for .net 4.0.

Maybe I'm bitter after wasting 1/2 day on this but there is no mention of this on the xUnit web site. In fact the site only talks about running the tests with VS. I found reference to the console runner on blog sites.

Starting to wonder about xUnit, maybe I should look at nUnit. It appears to at least have documentation.

like image 74
Mark Wagoner Avatar answered Apr 30 '23 04:04

Mark Wagoner