views:

210

answers:

2

I've recently installed MbUnit version 2.4.2.355 on our build server which runs via Cruise Control.NET and NAnt, on a Windows Server 2003 machine with .NET Framework 3.5 SP1 installed.

I've checked every nook and cranny of the build scripts, and the NAnt output report on CC.NET tells me that the test project builds fine.

This is the NAnt script:

<target name="compiletests" description="Compiles unit tests separately">
    <exec program="${netframework.dir}\msbuild.exe">
        <arg line="C:\dev\PROJ3.1\trunk\src\PROJ\Customer\CustomerUnitTests\Company.CustomerUnitTests.csproj  /t:Rebuild /p:Configuration=Debug"></arg>
    </exec>
</target>

And the output is the ff:

[exec] Company.CustomerUnitTests -> C:\dev\PROJ.1\trunk\src\PROJ\Customer\CustomerUnitTests\bin\Debug\Company.CustomerUnitTests.dll [exec] Done Building Project "C:\dev\PROJ.1\trunk\src\PROJ\Customer\CustomerUnitTests\Company.CustomerUnitTests.csproj" (Rebuild target(s)). [exec] Build succeeded. [exec] "C:\dev\PROJ3.1\trunk\src\PROJ\Customer\CustomerUnitTests\Company.CustomerUnitTests.csproj" (Rebuild target) (1) ->

What this means is that the build of the unit test assembly succeeded.

Thing is, at the end of the NAnt outputs is this:

mbunit-tests: [mbunit] MbUnit 2.4.2.355 test runner [mbunit] No test assemblies found in test

I've gone console and tried using MbUnit.Cons.Exe to manually test the compiled assemblies. The results went like this:

  • Test assemblies built using my Windows XP SP3 machine were properly recognized and the tests were being run properly on my machine, and on any other dev machine for that matter.
  • Test assemblies built in the build server running Windows Server 2003 weren't being recognized as test assemblies; I tried copying those files into my XP machine and they weren't recognized either.

I'm now wondering: what is the difference between a test assembly and a non-test assembly? I'm sure it has something to do with the Test and TestFixture attributes, but in my case, why are the assemblies compiled in WinXP machines compiled as tests, and those compiled the Win2K3 machine not recognized?

Hope someone has a clue on this.

+2  A: 

There is no fundamental difference as to whether any particular assembly is considered a test assembly.

My guess is that your dev machine is running a slightly different build of MbUnit than your build server. MbUnit v2 has cross-version compatibility issues that can cause it not to recognize tests properly (because it attempts to load a different version of the framework assembly than is installed).

Incidentally, these issues have largely been resolved in MbUnit v3.

If you haven't done so already, you may find it helpful to install a copy of MbUnit in your source tree. That will ensure that a consistent version is always used everywhere.

Jeff Brown
+4  A: 

First of all check this issue.
If this not help, you need to check target platform (project properties, build) to be "Any CPU". After this try to open assembly which is generated on your build machine using Reflector. May be generated files are corrupted. And also could you please try to build the project manually using VS and load generated tests in MbUnit.

zihotki
+1 for suggesting reflector. Thats the first thing I thought -- take a look and see if there are any differences between the build output from the different machines.
Peter Meyer