16
votes

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.

3
It is still an issue with 10.x and it is a problem because the build fails.Mukus
That's sad. I'm still effectively using the workaround though. Haven't got time to reconfigure and try out the no-workaround solution.Jurijs Kastanovs

3 Answers

42
votes

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.)

6
votes

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.

0
votes

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