16

I've recently updated to TeamCity 9.1.6 to run my new unit tests based on NUnit 3.2.1. But now I'm having trouble running the tests:

I've selected the NUnit3 executor in build steps, configured it accordingly:

Build step configuration

When building, I get an error: "Could not load file or assembly 'nunit.framework' or one of its dependencies. The system cannot find the file specified.".

Build log

Everything should be fine, the paths are fine, the assembly is in the path of the Test assembly, everything is built in AnyCPU configuration. There's also the error stating that NUnit version is not a release version, which I think is bullshit, it's a release on NUnit website. And the error doesn't seem to break anything (it was present even when I had an error before the 'nunit.framework' error, and when I fixed that one, the build got further).

Any leads appreciated!

UPDATE: Running tests using a Command Line runner and running that same nunit3-console.exe works fine. So I guess this is a NUnit runner specific problem. Still, suggestions are welcome on how to fix this.

UPDATE 2: I tried downgrading both the solution package and the NUnit-Console used by TeamCity to 3.0.0 - still, same result.

UPDATE 3: As I've suspected, TeamCity support confirmed that the message about "NUnit version not being supported" is a faulty one, and shouldn't affect anything.

Jurijs Kastanovs
  • 655
  • 1
  • 13
  • 32

3 Answers3

41

I had the same problem with TeamCity 10.0.1 (build 42078) and NUnit 3.4.1. And it turned out to be completely my fault. I'm posting it here as someone else can stumble into the same problem and this can save them some time.

It turned out that the problem was in the "Run tests from: " setting in my build configuration.

enter image description here

I had **\*.Test.dll. That was accidentally picking up dlls for \obj\**\ directories (where there is no nunit.framework.dll present). Once I changed the setting to **\bin\%BuildConfiguration%\*.test.dll it all works fine.

Note: %BuildConfiguration% is a parameter which specifies your preferred build configuration on the TC (like Debug / Release / CIBuild etc.)

milanio
  • 3,530
  • 20
  • 30
  • This helped out an error between JetBrains DotCover and NUnit which reported a return code of -100 showing my build pipeline which runs some integration tests as failed, despite all tests succeeded. After adding %BuildConfiguration% i could resolve the test assembly dlls. – Tore Aurstad Apr 25 '21 at 00:16
6

After a lengthy email discussion with TeamCity tech support we came to a solution. I've been notified that they've fixed this problem in the upcoming TC10 release (coming somewhere in the end of June 2016), and that for now there's a couple workarounds that will fix this.

I've tried number two, and it worked for me.

  1. Run tests only in the nested directories relative to the checkout directory (for example you could copy them before)

  2. Add a build configuration parameter nunit_use_project_file to False:

    Edit Parameter popup

    That is, I went to my test building and running projects, went to the Parameters section and added the new parameter "nunit_use_project_file" as False. Tests are now running under NUnit3 build step runner.

Jeroen
  • 53,290
  • 30
  • 172
  • 279
Jurijs Kastanovs
  • 655
  • 1
  • 13
  • 32
  • I was getting the same error and number 2 solution worked for me. But now after upgrading to teamcity 10.0.1, this error comes back and we are unable to run any of the tests. Any idea? – sam Aug 15 '16 at 07:27
  • @sam I would suggest trying to contact TeamCity support. They took a day or 2 to respond, but they did help. – Jurijs Kastanovs Aug 16 '16 at 05:57
  • This following link, like @Mathew 's comment above solved it for me: http://stackoverflow.com/a/3668371/502130 – mrkosko Mar 14 '17 at 13:50
  • Option 2 did not work for us.. same error, exit code -100. – diegohb Oct 22 '20 at 03:04
0

If you don't already have Nunit3 and Nunit.Console(Runner) in your packages.config you should "install" it to your project using the Package Manager.

Then follow the directions in this other answer about creating an "auto detect" step for the Nunit.ConsoleRunner. https://stackoverflow.com/a/38862220/3794873

Community
  • 1
  • 1
dragon788
  • 2,697
  • 1
  • 30
  • 44