MSBuild:在NUnit任务运行之前复制依赖项文件
我们正在从MSBuild:在NUnit任务运行之前复制依赖项文件,msbuild,nunit,testrunconfig,integration-testing,Msbuild,Nunit,Testrunconfig,Integration Testing,我们正在从MSTests迁移到NUnit。第一步是迁移使用以下msbuild任务完成的所有UnitTests项目: <Target Name="RunTests"> <!-- The location of the necessary tools to run nunit tests --> <PropertyGroup> <NUnitToolPath>C:\Program Files\NUnit 2.5.2\bi
MSTests
迁移到NUnit
。第一步是迁移使用以下msbuild任务完成的所有UnitTests项目:
<Target Name="RunTests">
<!-- The location of the necessary tools to run nunit tests -->
<PropertyGroup>
<NUnitToolPath>C:\Program Files\NUnit 2.5.2\bin\net-2.0</NUnitToolPath>
<NUnitResultTool>C:\Program Files\NUnit For Team Build Version 1.2</NUnitResultTool>
</PropertyGroup>
<!-- Create a build step representing running nunit tests -->
<BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Name="NUnitTestStep" Message="Running Nunit Tests">
<Output TaskParameter="Id" PropertyName="NUnitStepId" />
</BuildStep>
<!-- Specify which dll's to include when running tests -->
<CreateItem Include="$(OutDir)\Profdoc.UnitTests*.dll">
<Output TaskParameter="Include" ItemName="TestAssembly" />
</CreateItem>
<NUnit
Assemblies="@(TestAssembly)"
ToolPath="$(NUnitToolPath)"
OutputXmlFile="$(OutDir)\NUnit_TestResults.xml"
ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="NUnitResult" />
</NUnit>
<!-- Update the build step result based on the output from the NUnit task -->
<BuildStep Condition="'$(NUnitResult)'=='0'" TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(NUnitStepId)" Status="Succeeded" />
<BuildStep Condition="'$(NUnitResult)'!='0'" TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" Id="$(NUnitStepId)" Status="Failed" />
<!-- Upload the results to TFS. -->
<Exec Command=""$(NUnitResultTool)\NUnitTFS.exe" -n "$(OutDir)\NUnit_TestResults.xml" -t "$(TeamProject)" -b "$(BuildNumber)" -f "%(ConfigurationToBuild.FlavorToBuild)" -p "%(ConfigurationToBuild.PlatformToBuild)" -x "$(NUnitResultTool)\NUnitToMSTest.xslt"" />
<!-- Indicate build failure if any tests failed -->
<Error Condition="'$(NUnitResult)'!='0'" Text="Unit Tests Failed" />
</Target>
C:\ProgramFiles\NUnit 2.5.2\bin\net-2.0
C:\Program Files\n为团队构建版本1.2卸载
但是我不知道我们如何在没有集成测试的情况下完成同样的任务,因为我们需要在运行测试之前将设置和许可文件部署到二进制文件夹中。因此,我如何将文件部署到二进制文件夹,最好是作为NUnit任务的一部分(因为我想针对不同的配置设置运行IntegrationTests)?我建议创建一个新的目标,它将复制所有必需的文件,并使目标运行测试依赖于新的文件,基本上:
<PropertyGroup>
<LicenseFiles>$(PathToLicenseFiles)\**\*.lcx</LicenseFiles>
<SettingsFiles>$(PathToConfigFiles)\**\*.config</SettingsFiles>
</PropertyGroup>
<ItemGroup>
<Files Include="$(LicenseFiles);$(SettingsFiles)"
Exclude="*.tmp"/>
</ItemGroup>
<Target Name="CopyDependencyFiles">
<CopyFiles Inputs="@(Files)" Outputs="..." />
</Target>
<!-- Run Integration tests after all files were copied -->
<Target Name="RunIntegrationTests" DependsOnTargets="CopyDependencyFiles">
<NUnit .. />
</Target>
$(PathToLicenseFiles)\***.lcx
$(路径配置文件)\***.config