CC.NET:并行NUnit测试

CC.NET:并行NUnit测试,nunit,parallel-processing,cruisecontrol.net,Nunit,Parallel Processing,Cruisecontrol.net,我们有3个单元测试DLL,执行这些测试需要1小时(分别为30、20和10分钟)。同时运行,所需时间不超过30分钟 您是否知道在CC.Net或“内部”NUnit进程中并行执行NUnit是否可能,以及如何实现: 同时运行3个DLL 或者 在1个DLL中作为并行进程运行多个测试 我们最终通过MSBuild并行运行测试,然后将生成的(多个)测试结果文件合并到一个文件中以便于报告-CC.Net将很乐意在构建服务器上为您做到这一点,但对于开发人员来说,在他们自己的机器上也能获得有意义的结果也很好 示例

我们有3个单元测试DLL,执行这些测试需要1小时(分别为30、20和10分钟)。同时运行,所需时间不超过30分钟

您是否知道在CC.Net或“内部”NUnit进程中并行执行NUnit是否可能,以及如何实现:

  • 同时运行3个DLL
或者

  • 在1个DLL中作为并行进程运行多个测试

我们最终通过MSBuild并行运行测试,然后将生成的(多个)测试结果文件合并到一个文件中以便于报告-CC.Net将很乐意在构建服务器上为您做到这一点,但对于开发人员来说,在他们自己的机器上也能获得有意义的结果也很好

示例代码如下所示:

<Target Name="UnitTestDll">
  <Message Text="Testing $(NUnitFile)" />
  <ItemGroup>
    <ThisDll Include="$(NUnitFile)"/>
  </ItemGroup>
  <NUnit ToolPath="$(NUnitFolder)" Assemblies="@(ThisDll)" OutputXmlFile="$(TestResultsDir)\%(ThisDll.FileName)-test-results.xml" ExcludeCategory="Integration,IntegrationTest,IntegrationsTest,IntegrationTests,IntegrationsTests,Integration Test,Integration Tests,Integrations Tests,Approval Tests" ContinueOnError="true" />
</Target>

<Target Name="UnitTest" DependsOnTargets="Clean;CompileAndPackage">
    <Message Text="Run all tests in Solution $(SolutionFileName)" />
  <CreateItem Include="$(SolutionFolder)**\bin\$(configuration)\**\*.Tests.dll" Exclude="$(SolutionFolder)\NuGet**;$(SolutionFolder)**\obj\**\*.Tests.dll;$(SolutionFolder)**\pnunit.tests.dll">
    <Output TaskParameter="Include" ItemName="NUnitFiles" />
  </CreateItem>
  <ItemGroup>
    <TempProjects Include="$(MSBuildProjectFile)">
      <Properties>NUnitFile=%(NUnitFiles.Identity)</Properties>
    </TempProjects>
  </ItemGroup>
  <RemoveDir Directories="$(TestResultsDir)" Condition = "Exists('$(TestResultsDir)')"/>
  <MakeDir Directories="$(TestResultsDir)"/>

  <MSBuild Projects="@(TempProjects)" BuildInParallel="true" Targets="UnitTestDll" />

  <ItemGroup>
    <ResultsFiles Include="$(TestResultsDir)\*.xml" />
  </ItemGroup> 

  <NUnitMergeTask FilesToBeMerged="@(ResultsFiles)" OutputPath="$(MSBuildProjectDirectory)\TestResult.xml" />
</Target>

NUnitFile=%(NUnitFiles.Identity)

这是否回答了您的问题?