I have the following simple test case:
var uri = new Uri("http://foo.com/bar%2Fbaz");
Assert.AreEqual("http://foo.com/bar%2Fbaz", uri.AbsoluteUri);
This test fails on .NET 4 but passes on .NET 4.5, I can test this using ReSharper test runner which provides a handy CLR selection menu.
But if I run this test using nunit console runner like the following:
nunit-console.exe /framework:4.5 "C:\Data\Projects\UriTest\bin\Debug\UriTest.dll"
My tests get failed. I have even modified nunit-console.exe.config and added this:
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
and after adding this, I have started to get this output from runner:
Runtime Environment -
OS Version: Microsoft Windows NT 6.2.9200.0
CLR Version: 4.0.30319.34209 ( Net 4.5 )
ProcessModel: Default DomainUsage: Single
Execution Runtime: v4.5
But still my test fails. Any idea why this happens?
After taking a look more deeply at the issue, here's the information I gathered from different forums.
First, it should detect the runtime automatically. If it doesn't (which seems to be your case), you can always force the framework using the proper runtime by using the /framework command option.
What you have in the nunit-console.exe.config forces the NUnit runner to use the specified runtime. If your assembly is in a different .NET version, NUnit will run them in a separate process to force the framework version.
See the documentation for NUnit 2.6.2.
What you have in your command line shouldn't be /framework:4.5 but rather /framework:net-4.5
The next step would be to take a look at your test and see if there's something specific that makes it fail.
Please comment some more for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With