Problems running nunit 3 in TeamCity

Answered

I have been following the instructions to get nunit 3 running in Team city found here:

https://confluence.jetbrains.com/display/TCD9/Getting+Started+with+NUnit

My tests run locally on my dev box (in resharper and from the command line using a MSBuild script).

I tried to use the Nunit Build Step but I ran into strange problems:

  1. DLL reference problems, example:

System.IO.FileLoadException : Could not load file or assembly 'System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This test ran fine before the change to Nunit 3 and it runs fine locally.  This isn't the only DLL that is problem, different tests complain about different DLLs.  


     2.  Problems with Ninject.  I have some unit tests that verify things related to our dependancy injection.  

System.NotSupportedException : Error loading module 'Ninject.Web.Common.WebCommonNinjectModule' of type WebCommonNinjectModule

Another module (of type WebCommonNinjectModule) with the same name has already been loaded

Suggestions:

  1) Ensure that you have not accidentally loaded the same module twice.

  2) If you are using automatic module loading, ensure you have not manually loaded a module

     that may be found by the module loader.

This test ran fine before the change to Nunit 3 and it runs fine locally.


I created an Msbuild step to run my Test that runs the same target I run locally and this also runs find through TeamCity.  But with Unit tests running this way I don't get any code coverage.

Does anyone know how I can fix the above problems so I can get code coverage back?

3 comments

I have been able to reproduce the problem locally.  It seems to be releated to the way you generate the .nunit file.

The file you generate looks like :

<NUnitProject>

<Settings activeconfig="active" appbase="E:\Devel\Trunk1"/>

<Config binpath="app\source\myapp.Tests\bin\x86\debug;app\source\myapp.service.Test\bin\debug" name="active">

<assembly path="app\source\myapp.Tests\bin\x86\debug\LionsEye.Tests.dll"/>

<assembly path="app\source\myapp.service.Test\bin\debug\LionsEye.Uploader.Tests.dll"/>

</Config>

</NUnitProject>

If I run with this file locally it will fail in the same way.  However if I remove the 'binpath' variable, the tests will run fine:

<NUnitProject>

<Settings activeconfig="active" appbase="E:\Devel\Trunk1"/>

<Config name="active">

<assembly path="app\source\myapp.Tests\bin\x86\debug\LionsEye.Tests.dll"/>

<assembly path="app\source\myapp.service.Test\bin\debug\LionsEye.Uploader.Tests.dll"/>

</Config>

</NUnitProject>

Why is TeamCity Setting this? is there a way to make it stop setting this?

1

Hi,

 

Is there a solution to this problem ?

Could you please let me know?

Regards,

 

0

This problem should be fixed in 10.0: https://youtrack.jetbrains.com/issue/TW-43954

If you still have it, please upgrade your TeamCity server.

0

Please sign in to leave a comment.