Getting TeamCity to run NUnit tests with integrating both NCover and TypeMock?

Basically, I would like to use the NUnit plugin for TeamCity (a program, not necessarily a specific build step, using it) to run my unit tests with NCover to cover the code, and since my unit tests use TypeMock 6, I need this also worked.

So far I have tried:

  • Just basically pointing the build step of TeamCity NUnit to my dlls, but this fails with the following error message:

    The Typemock Isolator must be associated with the Coverage Tool to run in order to enable one of the following:

    • bind the Coverage tool through a Typemock isolator configuration
    • run tests through TMockRunner.exe -link
    • use TypeMockStart tasks for MSBuild or NAnt using a link
  • Trying to figure out the correct command line, I tried this:

    C: ... \ Isolator \ 6.0 \ TMockRunner.exe "C: \ TeamCity ... \ JetBrains.BuildServer.NUnitLauncher.exe" v4.0 MSIL NUnit-2.5.9 MyAssembly.dll

    This fails with the same error.

  • Setting the environment variables found in the file part mocking_on.batfor TypeMock, this does not change the result.

Please note that the above examples do not contain links to NCover (yet), since I have worked on the command line with the above examples for several hours and still have not received the base module - the tests are performed. NCover is an additional option for the nunit-launcher TeamCity, so I hope it is as simple as turning it on when I get to it.

+3
source
2

TypeMock , runner, TMockRunner, GUI TeamCity, .

msbuild :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TypeMockLocation>C:\Program Files (x86)\TypeMock\Isolator\6.0</TypeMockLocation>
        <NUnit>"C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe"</NUnit>
        <NCover>C:\Program Files (x86)\NCover\NCover.Console.exe</NCover>
    </PropertyGroup>
    <Import Project="$(TypeMockLocation)\TypeMock.MSBuild.Tasks"/>
    <Target Name="TestWithTypeMock">
        <TypeMockStart Link="NCover3.0" ProfilerLaunchedFirst="true" Target="2.0"/>
            <Exec ContinueOnError="true" Command="$(NUnit) v2.0 x86 NUnit-2.5.9 SqlDatabases.Core.Tests\bin\Debug\SqlDatabases.Core.Tests.dll SqlDatabases.SqlServer.Tests\bin\Debug\SqlDatabases.SqlServer.Tests.dll /ncover:%22$(NCover)%22 /ncover-arg://ias /ncover-arg:SqlDatabases.Core /ncover-arg://ias /ncover-arg:SqlDatabases.SqlServer /ncover-arg://et /ncover-arg:.*Exception /ncover-arg://x /ncover-arg:c:\temp\coverage.xml"/>
        <TypeMockStop/>
    </Target>
</Project>

TeamCity. , script , ( Visual Studio, - ). , 1 TeamCity, .

:

@echo off
setlocal
set CURDIR=%CD%
copy c:\dev\sqldatabases\tests.msbuild .\
msbuild tests.msbuild /target:TestWithTypeMock
rd /s /q c:\dev\sqldatabases\codecoverage
md c:\dev\sqldatabases\codecoverage
"c:\program files\ncover\ncover.reporting.exe" c:\temp\coverage.xml //or FullCoverageReport:Html:c:\dev\sqldatabases\codecoverage
cd \dev\sqldatabases\codecoverage
del %CURDIR%\coverage.zip
7z a -r %CURDIR%\coverage.zip

TeamCity:

  • Visual Studio: .
  • C:\Dev\SqlDatabases\Tests.bat( )

, coverage.zip , , .

, , , - , , TeamCity ( TypeMock), , , , TeamCity.

, - .

+4

,

, TeamCity, NCover . Typemock , , .

0

Source: https://habr.com/ru/post/1789260/


All Articles