views:

653

answers:

2

Hi, has anyone got NCover, TypeMock and MSTest to work together? and if so how.

I've had 2 or 3 serious tries at this now and just can't get it to work.

I'm using MSTest 9, NCover 2.1 and TypeMock 4.1.

Ideally I would like to run them from an MSBuild task.

Cheers Mat

+1  A: 

Try this blog post .. seems relevant but may not answer the question http://weblogs.asp.net/bsimser/archive/2006/12/08/msbuild-nant-nunit-mstest-and-frustration.aspx

Peter Marshall
+2  A: 

Well its a bit late but here is the answer for future generations ...
Few key points:

  • In older version of Typemock (like 4.1) you need an enterprise license in order to run Typemock with NCover. In the current version all licenses have the same features list.
  • In order to run Typemock with other profilers you need to use the link feature of Typemock. In your case you can do it with Typemock MSBuild task.
  • You need to run MSTest with the /noisolation argument. This will prevent MSTest to spawn VSTestHost.exe process that will actually run your tests. This creates a problem enabling the environment variables that are needed in order to let the profilers work

In the example below I'm running the tests in Tests.dll and asking for coverage report about ClassLibrary.dll

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="RunTests" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;

<Import Project ="c:\Program Files\Typemock\Isolator\5.2\TypeMock.MSBuild.Tasks" />

    <PropertyGroup>
     <NCOVER>"E:\src\TypeMock\Build\Binaries\NCover\NCover 2.0\NCover.Console.exe"</NCOVER>  
     <MSTest>"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"</MSTest>    
    </PropertyGroup>

    <Target Name ="Test">
     <TypeMockStart Target="2.0" Link ="NCover2.0"/>
    <Exec ContinueOnError="true"  Command="$(NCOVER) //a ClassLibrary $(MSTest) /noisolation /testcontainer:E:\src\TestNcover3\MSBuildTest\bin\Debug\Tests.dll" />
    <TypeMockStop/>
</Target>
</Project>
Ohad Horesh