gpt4 book ai didi

nunit - CC.NET:并行化NUnit测试

转载 作者:行者123 更新时间:2023-12-01 04:06:39 26 4
gpt4 key购买 nike

我们有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>

关于nunit - CC.NET:并行化NUnit测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8894295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com