Starting Typemock Isolator

The typemockstart task runs Typemock Isolator on the server.

To run typemockstart:

Add the typemockstart task to the project file with the following optional parameters:

Parameter

Description

Type

Mandatory/Optional

version

Typemock Isolator version

String

Optional

target

.NET version.

Possible values:

2.0

3.0

3.5

3.0

4.0

4.5

String

Optional

logPath

Path to log files (by default, it is the Typemock Isolator installation directory)

String

Optional

Link

Integrates Typemock Isolator with a specified profiler

String

Optional

DisableAutoLink

Disables automatic integration with profilers

Boolean

Optional

Sample 1: Running NUnit Tests and Typemock Isolator

Because the best practice recommends to copy the Typemock Isolator DLLs to the source control repository, the following example assumes that the DLLs are stored there (see the TypemockLocation parameter). Your build can retrieve the files from the source control repository.

The original location of the DLLs is C:\Program Files (x86)\TypeMock\Isolator\<version>\TypeMock.NAnt.dll.

<project name="Typemock Isolator Examples" default="test" basedir=".">
  <property name="nunit" value="C:\Program Files\NUnit\bin\nunit-console.exe" />
  <property name="typemock.dir" value="C:\Sources\TypeMock" />

  <!--Example: running NUnit tests with Typemock Isolator-->
  <target name="test">
    <!-- Dynamically load Typemock NAnat tasks -->
    <loadtasks assembly="${typemock.dir}\TypeMock.NAntBuild.dll" />

    <!-- Start Typemock Isolator -->
    <typemockstart/>
    <!-- Stop Typemock Isolator -->
    <typemockstop/>
  </target>
</project>

Sample 2: Running NUnit Tests with Typemock Isolator and NCover 2.x Coverage in .NET 4.0

This is done using the <ncover> NAnt task provided with NCoverExplorer, which comes with the NCover 4.x installation.

<project name="Typemock Isolator Examples" default="test" basedir=".">
  <property name="nunit" value="C:\Program Files\NUnit\bin\nunit-console.exe" />
  <property name="ncover.dir" value="C:\Program Files\NCover\NCover.Console.exe" />
  <property name="typemock.dir" value="C:\Sources\TypeMock" />

  <!--Example: running NUnit tests with Typemock Isolator and NCover 2.x coverage -->
  <target name="test" description="Execute NUnit tests with Typemock Isolator, and generate coverage information with NCover 2.x">
    <!-- Dynamically load Typemock NAnat tasks -->
    <loadtasks assembly="${typemock.dir}\TypeMock.NAntBuild.dll" />

    <!-- Load NCover NAnt tasks -->
    <loadtasks assembly="${ncover.dir}\Build Task Plugins\NCoverExplorer.NAntTasks.dll" />

    <!-- Start Typemock Isolator -->
    <typemockstart target="2.0"/>

    <!-- Run NCover with NUnit; Do NOT register the NCover profiler - this conflicts with the Typemock/NCover link -->
    <ncover program="${ncover.dir}\NCover.Console.exe"
      commandLineExe="${nunit}"
      commandLineArgs="Tests.dll"
      registerProfiler="false"
    />

    <!-- Stop Typemock Isolator -->
    <typemockstop/>
  </target>
</project>

Pre .NCover 4. Typemock Isolator requires registering its own profiler when linking with the NCover profiler. If you do not set registerProfiler="false", NCover will try to register its profiler when run and unregister Typemock Isolator, causing unexpected test failure.

You can use the same syntax for usage with NCover 1.5.8 by downloading the NCoverExplorer Extras package.

Sample 3: Running Ncover 4 Tests with Typemock Isolator and NCover 1.5.8 Coverage

The following example shows how to run NUnit tests with Typemock Isolator and NCover 1.5.8 coverage by using the generic NAnt <exec> task.

<project name="Typemock Isolator Examples" default="test" basedir=".">
  <property name="nunit" value="C:\Program Files\NUnit\bin\nunit-console.exe" />
  <property name="ncover.dir" value="C:\Program Files\NCover\NCover.Console.exe" />
  <property name="typemock.dir" value="C:\Sources\TypeMock" />

  <!--Example: running NUnit tests with Typemock Isolator and NCover 1.5.8 coverage -->
  <target name="test" description="Executes NUnit tests with Typemock Isolator, and generates coverage information using NCover 1.5.8">
    <!-- Dynamically load Typemock NAnat tasks -->
    <loadtasks assembly="${typemock.dir}\TypeMock.NAntBuild.dll" />

    <!-- Start Typemock Isolator -->
    <typemockstart target="2.0"/>

    <!-- Run NCover with NUnit using the NAnt exec task -->
    <exec failonerror="false" program="${ncover.dir}\NCover.Console.exe">
      <arg value="${nunit}" />
      <arg value="Tests.dll" />
    </exec>

    <!-- Stop Typemock Isolator -->
    <typemockstop/>
  </target>
</project>