我使用typemock进行单元测试。如何开始构建使用typemock。 我只能使用typemock和msbuild吗?否则我应该使用nunit-console.exe吗?
当我使用单元测试启动构建时... 我的臭虫在哪里?
<Import Project="C:\Program Files (x86)\Typemock\Isolator\7\TypeMock.MSBuild.Tasks" />
<Target Name="BeforeTest">
<TypeMockStart LogPath="C:\TypeMockLogs" LogLevel="9" Target="3.5" />
<Exec ContinueOnError="false" WorkingDirectory="$(SolutionRoot)" Command="$(NUNIT) \bin\Debug\Business.Tests.dll" />
</Target>
<Target Name="AfterTest">
<TypeMockStop Undeploy="true" />
</Target>
<PropertyGroup>
<TypeMockLocation>C:BuildIsolator</TypeMockLocation>
<NUNIT>"C:\Program Files (x86)\NUnit 2.6\bin\nunit-console.exe"</NUNIT>
<TMockRunnerPath>"C:\Program Files (x86)\Typemock\Isolator\7\TMockRunner.exe"</TMockRunnerPath>
<MSTestPath>"D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe"</MSTestPath>
</PropertyGroup>
答案 0 :(得分:2)
为了使用MSBuild运行测试,您需要使用TypeMockStart&amp; TypeMockStop任务或改为使用TMockRunner。更简单的方法是使用Start&amp;停止:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TypeMockLocation>C:\Program Files\TypeMock\Isolator\5.0</TypeMockLocation>
<NUnit>"C:\Program Files\NUnit\bin\nunit-console.exe"</NUnit>
</PropertyGroup>
<Import Project ="$(TypeMockLocation)\TypeMock.MSBuild.Tasks"/>
<Target Name="TestWithTypeMock">
<TypeMockStart/>
<Exec ContinueOnError="true" Command="$(NUnit) Test.dll"/>
<TypeMockStop/>
</Target>
</Project>
此示例假定构建代理程序已安装Isolator。如果不是,您还需要在开始之前调用注册任务,您可以找到它的文档here
<TypeMockRegister Company ="TypeMock" License="TypeMockLicense" AutoDeploy="True"/>
免责声明 - 我在Typemock工作