NUnit not picking up .net Framework Version
We're trying out AppVeyor to be our CI solution for a large .NET project. We target .NET 4.5.1 and use NUnit, and the build works perfectly and the tests are discovered correctly. However, the nunit test runner consistently targets .NET 3.5 rather than 4.5, causing a couple of tests specific to 4.5 functionality to fail.
We've tried a couple approaches to resolve this issue, including a build script similar to: "nunit-console C:\projects\optirtcazure-bju5m\OptiRTC.APIHelpers.Tests\bin\Debug\OptiRTC.APIHelpers.Tests.dll /framework:net-4.5", which targets the specific project we have with the tests that fail in < 4.5.
Two questions: how can we get the nunit test runner to use the 4.5 framework, and can we do that while still having our tests autodiscoverable (we have many test projects, so this is absolutely necessary for us.)
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 20 Feb, 2015 06:02 PM
Hi Amanda,
So, did adding
/framework:net-4.5
work?2 Posted by Amanda Kabak on 20 Feb, 2015 06:04 PM
No, it still used 3.5. This is an excerpt from the console results:
nunit-console
C:\projects\optirtcazure-bju5m\OptiRTC.APIHelpers.Tests\bin\Debug\OptiRTC.APIHelpers.Tests.dll
/framework:net-4.5
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1889>NUnit-Console
version 2.6.3.13283
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1890>Copyright
(C) 2002-2012 Charlie Poole.
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1891>Copyright
(C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1892>Copyright
(C) 2000-2002 Philip Craig.
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1893>All
Rights Reserved.
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1894>
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1895>Runtime
Environment -
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1896>
OS Version: Microsoft Windows NT 6.2.9200.0
<https://ci.appveyor.com/project/AmandaKabak/optirtcazure-bju5m/build/1.0.20#L1897>
CLR Version: 2.0.50727.8009 ( Net 3.5 )
Support Staff 3 Posted by Feodor Fitsner on 20 Feb, 2015 06:12 PM
OK, how do you manage to run that locally?
4 Posted by Amanda Kabak on 20 Feb, 2015 06:16 PM
We run it through the NUnit plug in visual studio. We tried to using the vs
test runner on AppVeyor, but it didn't discover our tests in the project we
specified.
Support Staff 5 Posted by Feodor Fitsner on 20 Feb, 2015 06:24 PM
OK, I'm going to create a simple test project targeting 4.5.1 and see how it gets run by NUnit.
Support Staff 6 Posted by Feodor Fitsner on 20 Feb, 2015 06:55 PM
Would you recommend a simple .NET 4.5-specific code that fails if run under 3.5?
7 Posted by Amanda Kabak on 20 Feb, 2015 07:07 PM
The ones that fail in AppVeyor are specifically related to the same issue
that was reported here (with xUnit):
http://help.appveyor.com/discussions/problems/996-unit-tests-all-work-on-my-dev-machine-but-some-fail-in-appveyor
.
Some code that reproduces the issue (fails in < 4.5) is:
string expected = "%24skiptoken=1000&%24top=200";
Uri uri = new Uri("
https://data.test.com:81/api/project/?%24skiptoken=1000&%24top=200");
uri.ToString().Contains(expected); //returns true in 4.5 and when run
locally; false in < 4.5 and when run on appveyor
Support Staff 8 Posted by Feodor Fitsner on 20 Feb, 2015 07:18 PM
Seems formatting was eaten.
So, the following test should pass locally?
9 Posted by Amanda Kabak on 20 Feb, 2015 07:27 PM
Yes, exactly.
Support Staff 10 Posted by Feodor Fitsner on 20 Feb, 2015 07:52 PM
Well, it doesn't work locally:
Test:
11 Posted by Amanda Kabak on 20 Feb, 2015 07:55 PM
I took the test code, put it in a visual studio class and ran it within
Visual Studio 2013, and it passes. In the results you sent along, I see 3.5
specified in the NUnit runtime version:
Runtime Environment -
OS Version: Microsoft Windows NT 6.2.9200.0
CLR Version: 2.0.50727.8009 ( Net 3.5 )
Support Staff 12 Posted by Feodor Fitsner on 20 Feb, 2015 08:10 PM
Yeah, but then it shows correct "Execution runtime: net-4.5", no?
-Feodor
13 Posted by Amanda Kabak on 20 Feb, 2015 08:12 PM
It does, but I don't think it's using it given the CLR version above and
the test failing. Again, that test passes when I run it within my local
visual studio.
Support Staff 14 Posted by Feodor Fitsner on 20 Feb, 2015 08:30 PM
Looks like your case: http://stackoverflow.com/questions/27019061/forcing-nunit-console-runner-to-use-clr-4-5
Too bad there's no solution yet.
-Feodor
15 Posted by Amanda Kabak on 20 Feb, 2015 08:42 PM
Ah. Hm. Well, we do still want to use appveyor. Do you have any suggestions
as to how we can get this to work?
Support Staff 16 Posted by Feodor Fitsner on 20 Feb, 2015 09:54 PM
OK, more information on the problem: https://github.com/nunit/nunit/issues/244
...and the issue it started from: https://github.com/nunit/nunit/issues/237
Should be "fixed" like in beta 1 of nunit 3.0.
I would just comment/ignore/skip that test to make it work with
nunit-console
.Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:54 AM.