4

I am trying to use NUnit 3.0 Console runner with Teamcity. Here is my confiuration.

enter image description here

When I run the configuration, I get the following error

>  Run Unit Tests (NUnit) (1s)
[10:44:03][Step 3/3] ##teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_3' value='0.0']
[10:44:03][Step 3/3] Starting: C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07\Libs\NUnit.Console.3.0.1\tools\nunit3-console.exe C:\TeamCity\buildAgent\temp\buildTmp\O1YAIPlezg1Cm2NfZTD88h0Nb2Q14zOF.nunit --work=C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07 --noresult --noheader
[10:44:03][Step 3/3] in directory: C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07
[10:44:03][Step 3/3] Runtime Environment
[10:44:03][Step 3/3]    OS Version: Microsoft Windows NT 10.0.10586.0
[10:44:03][Step 3/3]   CLR Version: 4.0.30319.42000
[10:44:03][Step 3/3] 
[10:44:03][Step 3/3] Test Files
[10:44:03][Step 3/3]     C:\TeamCity\buildAgent\temp\buildTmp\O1YAIPlezg1Cm2NfZTD88h0Nb2Q14zOF.nunit
[10:44:03][Step 3/3] 
[10:44:04][Step 3/3] 
[10:44:04][Step 3/3] Errors and Failures
[10:44:04][Step 3/3] 
[10:44:04][Step 3/3] 1) Invalid : C:\TeamCity\buildAgent\temp\buildTmp\O1YAIPlezg1Cm2NfZTD88h0Nb2Q14zOF.nunit
[10:44:04][Step 3/3] Format of the executable (.exe) or library (.dll) is invalid.
[10:44:04][Step 3/3] 
[10:44:04][Step 3/3] Test Run Summary
[10:44:04][Step 3/3]     Overall result: Failed
[10:44:04][Step 3/3]    Tests run: 0, Passed: 0, Errors: 0, Failures: 0, Inconclusive: 0
[10:44:04][Step 3/3]      Not run: 0, Invalid: 0, Ignored: 0, Explicit: 0, Skipped: 0
[10:44:04][Step 3/3]   Start time: 2016-02-08 02:44:04Z
[10:44:04][Step 3/3]     End time: 2016-02-08 02:44:04Z
[10:44:04][Step 3/3]     Duration: 0.006 seconds
[10:44:04][Step 3/3] 
[10:44:04][Step 3/3] Process exited with code -2
[10:44:04][Step 3/3] ##teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_3' value='1095.0']
[10:44:04][Step 3/3] Step Run Unit Tests (NUnit) failed

From the error, I am guessing that it cannot find the Dll to run tests but I have checked the path and file in checkout directory, everything seems correct. Kindly tell me what am I doing wrong?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Afraz Ali
  • 2,672
  • 2
  • 27
  • 47
  • I am not sure what is the problem, but instead of using NUnit version 3.0, I reverted back to version 2.6.4 and everything is working fine. My only guess is that there is something wrong with NUnit 3.0 compatibility with Team City but I am not sure. – Afraz Ali Feb 10 '16 at 06:10
  • "Format of the executable ..." means that x86 and x64 binaries were mixed up. Have you compiled your tests for x86 perhaps? On a x64 system nunit-console.exe is JITed to 64-bit. Try passing the `--x86` [parameter](https://github.com/nunit/docs/wiki/Console-Command-Line) – Panagiotis Kanavos Mar 01 '16 at 12:49
  • Which nuget package were you using to get the console runner? Take a look at this: https://github.com/nunit/nunit/issues/1525 – Chris May 27 '16 at 20:49

2 Answers2

2

Run manually the tests using the commands that team city is using:

In the directory C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07 run : C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07\Libs\NUnit.Console.3.0.1\tools\nunit3-console.exe C:\TeamCity\buildAgent\temp\buildTmp\O1YAIPlezg1Cm2NfZTD88h0Nb2Q14zOF.nunit --work=C:\TeamCity\buildAgent\work\e6cc09e5f0da4a07 --noresult --noheader

See https://github.com/nunit/docs/wiki/Console-Command-Line for more parameters

You could get more information out of it if you increase the tracing information.

Also, there if you're running code coverage using the JetBrains dotCover, it will fail even if tests succeed. Try disabling code coverage if that's the case.

Cristian
  • 21
  • 2
  • 2
    Hi Christian, Thank you for your reply, I am afraid I do not understand, why can I not run the console runner by giving it the path of the unit test Dll? I have tried to run Nunit Console test manually using command prompt and pointing it to the Dll and it works correctly but when I run the same command from Team City it fails. I am not using JetBrains DotCover for now. – Afraz Ali Feb 18 '16 at 02:48
1

To make it work I used NuGet to add NUnit.ConsoleRunner v 3.5.0 to my project. Then I got an error: "File type is not supported", to fix that I added NUnit.Extension.NUnitProjectLoader v 3.5.0. (I tried to use NUnit.Extension.VSProjectLoader but that did not solve my issue)