NUnit v3 command line options

354 views
Skip to first unread message

andrius...@gmail.com

unread,
Mar 12, 2015, 6:12:58 PM3/12/15
to nunit-...@googlegroups.com
Hello,

I was very excited when I heard about V3 version of NUnit and it's ability to launch tests in parallel.

Previously I've used NUnit 2.6.4. So I've updated NUnit package to v3 version using NuGet. Then updated some deprecated attributes so my tests project compiles. My tests assemblies uses .NET 4.5.

Now I'm trying to launch unit tests using nunit-console. Here's the command line, that I'm using:

nunit-console.exe C:\Tests\My.Tests.dll --include=Unit --framework=v4.5 --out=TestResult.txt --err=StdErr.txt --result=TestResult.xml;format=nunit2 --labels=On --teamcity

When I execute this command, I get the following error:

Could not load file or assembly 'file:///C:\Tests\My.Tests.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

I've tried to omit "--framework=v4.5" option, but then I get this error:

Could not load file or assembly 'nunit.framework' or one of its dependencies. The system cannot find the file specified.

Any ideas what am I doing wrong? Maybe new version doesn't support .NET 4.5?

BTW: If I get this command line working, I'm going to use it in TeamCity. So what does "--teamcity" option exactly do? Documentation says "Turns on use of TeamCity service messages." What does it mean? Will my tests results be reported to TC on-the-fly using service messages?

Cheers,
Andrew

Charlie Poole

unread,
Mar 12, 2015, 6:21:52 PM3/12/15
to NUnit-Discuss
Hi Andrew,

NUnit 3.0 definitely supports .NET 4.5. In fact, you should be
referencing the .NET 4.5 build of the framework in your test assembly.
Can you verify that you are?

My first suspicion was that you might not be actually running the 3.0
console runner. This is unlikely, since you have some new 3.0 options
in the command line but take a look at the output and see what the
version number of the console runner is just to be sure. Are you using
the alpha 5 release of the console, engine and framework?

The --framework option is only needed if you want to run something
under a different framework version than what you compiled for.
Without it, NUnit checks the test assembly before deciding how to run
it. I think having a different error message is simply due to the fact
that some additional code is executed when --framework is not present.

Charlie
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.
> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

andrius...@gmail.com

unread,
Mar 12, 2015, 7:27:10 PM3/12/15
to nunit-...@googlegroups.com
Hi Charlie,

Thank you for a quick response!

That was my amateur mistake, that I've copied only Tests.dll, Tests.dll.config and Tests.pdb files into the same folder. When I copied everything, what VS compiled into Debug folder - command line worked!

I've also tried it in TC. Service messages works great - test results are visible on-the-fly! Awesome! Can't wait to try parallelism!

Just in case if anyone wonders, I've ended up with the following command line:

nunit-console.exe C:\Tests\My.Tests.dll --include=Unit --result=TestResult.xml;format=nunit2 --labels=On --teamcity

Keep up the good work!

Thank you,
Andrew 

andrius...@gmail.com

unread,
Mar 12, 2015, 8:18:56 PM3/12/15
to nunit-...@googlegroups.com
I've noticed strange behavior.

When tests finishes in TeamCity, I can find in build log nice summary:

[00:04:24][Step 1/1] Test Run Summary
[00:04:24][Step 1/1]     Overall result: Failed
[00:04:24][Step 1/1]    Tests run: 540, Passed: 539, Errors: 0, Failures: 1, Inconclusive: 0
[00:04:24][Step 1/1]      Not run: 2, Invalid: 0, Ignored: 2, Skipped: 0
[00:04:24][Step 1/1]   Start time: 2015-03-13 00:01:12Z
[00:04:24][Step 1/1]     End time: 2015-03-13 00:04:23Z
[00:04:24][Step 1/1]     Duration: 191.414 seconds

But in TeamCity builds overview page I see different numbers:

Tests failed: 1, passed: 359, ignored: 2 in "RunUnitTests" build step

I'm using FAKE library for my build script and when any of my build step fails - I'm sending the following TC service message:

##teamcity[buildStatus status='FAILURE' text='{build.status.text} in \"%s\" build step']

According to TC documentation "{build.status.text}automatically calculates passed test count.

Is that possible, that after first failed test nunit console stops sending service messages to TeamCity?

Charlie Poole

unread,
Mar 12, 2015, 11:03:52 PM3/12/15
to NUnit-Discuss
The code in NUnit that generates the service messages has no access to
any information about the run except for the current test result. But
of course there could be some other bug in NUnit.

The best way to find this out is to run your tests outside of
TeamCity, but use the --teamcity option. You'll see all the TeamCity
service messages on the console.

andrius...@gmail.com

unread,
Mar 13, 2015, 1:24:00 PM3/13/15
to nunit-...@googlegroups.com
I've redirected tests output to file and counted service messages. Looks like, that everything is correct ("##teamcity[testStarted" count equals 542). Probably TeamCity fails to process all messages before build finishes..
Reply all
Reply to author
Forward
0 new messages