i am new to TeamCity and i am trying to configure it to build and run all the unit test in the solution. it is working fine for the test which are not using TypeMock but its failing for those which is using TypeMock.

i have gone through a lot of posts on typemock.org and stackoverflow too but i didnt get any clear step by step solution to fix this.

What i did yet is

added the list of assemblies which i am using

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MsTest.exe
C:\TeamCity\AutoDeploy\TypeMock.dll
C:\TeamCity\AutoDeploy\TypeMock.MSBuild.dll
C:\BuildAgent\work\d0c2681a8633b717\www.Domain.Tests\bin\Release\qqq.Domain.Tests.dll

i am missing some build configuration but i am not sure if i have to do it for MSTest too

有帮助吗?

解决方案

Disclaimer I work at Typemock.

The best solution in your case is to use some kind of a build script like MSBuild or nant
If you are not using a build script you can set the TeamCity process to run with Isolator enabled. Here are the steps to do this:

  • In TeamCity projects page go to project you wish to change and hit Settings.
  • In the settings page go to the build parameters and choose edit.
  • In edit page choose add new parameter.
  • In the edit box in the Type section select Environment variable (env.)
  • In the Name text box put Cor_Enable_Profiling
  • In the value text box put 0x1
  • Hit the Save button

Repeat the steps above one more time but change the name of the environment variable to COR_PROFILER and the value to {B146457E-9AED-4624-B1E5-968D274416EC}

This will cause the TeamCity and its child processes (like msbuild) to run profiled with Isolator. Again, I don't think this is the best solution but it should do the job for you.

其他提示

I think you are gettig this error because, you did not configure TypeMock to run the test using MSTest. This you can do if did not do yet in your TeamCity Build Agent machine by following the below steps:

  1. Windows "Start" >> All Programs >> TypeMock Folder >> Isolator Folder >> Open Isolator Configuration
  2. In the new windows opened under Profilers/Code Coverage tab, check the check box Show only available profilers and in the drop down above that it should list NCover (This is with the assumption that you are using NCover for profiling unit test cases coverage and all).
  3. Select NCover from drop down and click on Link with TypeMock Isolator.

By this TypeMock Isolator will be configured to profile unit test as well and by that I think your TypeMock disabled issue will be resolved I hope.

EDIT:

Sorry for the wrong point. The above will help you if you are using profilers like NCover in your build.

You should use the below MSBuild to run test using MSTest and TypeMock:

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

    <UsingTask TaskName="NCover.MSBuildTasks.NCover" AssemblyFile="C:\Program Files\NCover\Build Task Plugins\NCover.MSBuildTasks.dll" />
    <Import Project ="C:\Program Files (x86)\Typemock\Isolator\6.1\TypeMock.MSBuild.Tasks" />

    <PropertyGroup>
         <MSTest>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"</MSTest>    
    </PropertyGroup>


    <Target Name ="RunTests">
         <TypeMockStart Target="3.5" />
         <Exec ContinueOnError="true"  Command='$(MSTest) /noisolation "/testcontainer:C:\continuousintegration\root\CTM_VPOFFICEClassLibraries\CTM.VPOffice\CTM.VPOffice Unit Testing\bin\Release\CTM.VPOffice Unit Testing.dll"' />
         <TypeMockStop />
    </Target>
</Project>

You can ignore the NCover related things in the above sample and the just ignore the Isolator Configuration steps if you don't have Test profiling in your build process.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top