Problems running nunit under visual studio builder

All,

I have a vs2008 solution that is built successfully within team city. I am using NUnit 2.5.5. for my unit tests.

When I run the unit tests locally all is well, however when team city attempts to run the tests they all fail. Looking more closely one of the test project uses MOQ, when testing team city cannot resolve the reference to this dll, however the dll is resolved successfully at build time. Does Team city require some addtional config to see this dll above and beyond what the Nunit framework requires?

I am quite new with Teamcity so its possible I have not configured something correctly but am struggling to track down what that is.

Thanks for any advice you may have.

13 comments

How have you set up unit tests under TeamCity? Please attach screenshot(s).

0

Thank you for your response, please find screenshot attached



Attachment(s):
buildsetting.png
0

Please check all references are available on build agent. If you use some GAC references, make sure those assemblies are registered into the GAC on the build agent machine. Are your references compiled for MSIL or x86/x64. If they are compiled for x86/x64, please check you selected the same value in tests settings. The last issue could be the user account that is used to run build agent service, please check it too.

Please attach the build log with test failure exception stacktrace.

0

I've checked as you advised and all the settings looked correct. I've stripped down and attached a log file, it seems to be struggling to find the MOQ library, however as I can build this project just fine I don't understand why the test runner would fail to resolve the reference.



Attachment(s):
moqlogerror.txt.zip
0

Please try running the build with MSBuild.exe from commandline on the build agent from the same directory under the same user account as used to run build agent windows service.

0

Running msbuild under the same account as that used for the build agent works fine. The problem relates to the nunit test runner in temcity being unable to resolve the references in my tests.

0

Please try setting x86 in NUnit test runner settings.

0

Same result;

Test(s) failed. System.IO.FileNotFoundException : Could not load file or assembly 'Moq, Version=3.0.204.1, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The system cannot find the file specified.
    at CS.PrimeDeployment.UnitTests.CommandBuilding.CanAddCommandsToCommandGroup()

0

Do you have this assembly on the build agent? What are the dependencies of that assembly?

0

Yes I have the assembly on the build machine; otherwise my build would not work. All dependencies must be satisfied otherwise the solution would not build, its the test runner that cannot resolve the assemblies at runtime for reasons that I cannot understand. The logs reveal that its hunting around for the moq.dll and cannot find it - why it would not simply use the reference in the test project that has already built is unclear.

0

Ok, could you please try running this assembly with NUnit-Console.exe. Do you have all references available on the same folder as test assembly? Do you have custom assembly configuration files, policy redirection or kind of?

0

Running nunit-console from the command window fails with the same error. I've noticed that dependent external dlls such as Moq and project references that are under test are not copied in to the testing folder and as such test test runner is failing. All the dlls have 'copy local' set to true so I'm not sure why they're not being copied in.

0

It seems to be the issue. You may add a build script to explicitly copy all dependencies before running a tests. This could also work locally, bacause those assemblies are available in GAC.

0

Please sign in to leave a comment.