dotnet-test-nunit icon indicating copy to clipboard operation
dotnet-test-nunit copied to clipboard

nunit3-console doesn't work with .NET versions past 4.5

Open fandrei opened this issue 7 years ago • 7 comments

nunit3-console.exe MyTestAssembly.dll /framework:net-4.7 /work:TestResults

Results in:

The requested framework net-4.7 is unknown or not available.

The same results for net-4.5.2, net-4.6, net-4.6.2 Only net-4.5 works

fandrei avatar May 15 '17 03:05 fandrei

While your statement is correct, I'm not 100% sure what we should do about it. We might want to add other options to those four that are supported or it may simply be a matter of documentation.

The /framework option is used when you want an assembly built to target a particular runtime to run under a different runtime. Is that the case in your usage?

I assume that your test is referencing the net-4.5 build of the NUnit framework, which is compatible with the higher-level runtimes you list.

CharliePoole avatar May 15 '17 04:05 CharliePoole

@CharliePoole,

  1. I think that it should be documented, at least.
  2. They are not entirely compatible, the framework libraries are different. Running the tests in a different environment can result in false positives or false negatives.

fandrei avatar May 15 '17 05:05 fandrei

Can you clarify point 2? Is there something that doesn't work when you run the tests normally without the /framework option?

We don't build the framework for a higher level that 4.5 because we don't make use of any features beyond those that 4.5 supports. Our four builds (2.0, 3.5, 4.0 and 4.5) have some slight differences, but we have not found any need to add further builds so far. Your tests should run automatically under the 4.7 framework, if that's what you targeted, unless you specify a /framework option.

CharliePoole avatar May 15 '17 05:05 CharliePoole

@CharliePoole, just theoritizing :)

One possible problematic place is GCSettings.LargeObjectHeapCompactionMode added in 4.5.2, but I haven't had any problems so far.

Your tests should run automatically under the 4.7 framework, if that's what you targeted, unless you specify a /framework option.

How does it detect it?

fandrei avatar May 15 '17 05:05 fandrei

On documentation... we currently only say "Examples: mono, net-4.5, v4.0, 2.0, mono-4.0" which doesn't tell you exactly what is supported and what isn't. We should at a minimum provide a complete list of what is accepted. Ideally, we should accept through 4.7 and act on it.

CharliePoole avatar May 15 '17 05:05 CharliePoole

@fandrei Since that's not a feature we use in NUnit, we would not need to build to the 4.7 framework because of it. Your code, of course, can take advantage of it, while still referencing libraries built to target the 4.5 runtime - or even 2.0 for that matter.

We determine the target runtime by examining the TargetFrameworkAttribute. The process launched to run your tests should be running under that runtime. If you see it isn't, of course, then we have an additional bug.

CharliePoole avatar May 15 '17 05:05 CharliePoole

@CharliePoole, it seems that everything's fine. The only problem is documentation. And the error message is a bit misleading. Thanks for your help.

fandrei avatar May 15 '17 05:05 fandrei