单元测试在构建服务器上执行缓慢
Unit tests slow execution on build server
我有一个 .NET 解决方案,其中包含一些作为 nuget 包发布的 Service Fabric 库项目 (.NET Standard 2.0)。解决方案 (.NET Core 2.0) 中的单元测试项目正在使用 xUnit。
我注意到在构建服务器上 运行 时测试花费了太多时间,与以前的构建 相比。
我使用 Reshaper/Visual Studio 或 powershell 脚本在我的本地机器上尝试了 运行 测试,它只用了不到 5 分钟:
$stopwatch = [system.diagnostics.stopwatch]::StartNew()
Get-ChildItem -recurse *tests.csproj | % {
dotnet test $_.FullName --no-build --no-restore;
}
$stopwatch.Stop()
Write-Host $stopwatch.Elapsed
但在 Azure Devops 中,单元测试任务需要超过 27 分钟才能完成!!!
这是构建 pipeline/unit 测试任务:
知道发生了什么吗?
在 Regression: dotnet test hangs for 15 minutes after test run completed on mac and linux 中找到了解决方案。
将以下参数添加到 dotnet build
任务的参数中就可以了:
-nodereuse:false
顺便说一句,生成代理是 Windows mac 海因斯,而不是上述问题中提到的 mac 或 linux。
我有一个 .NET 解决方案,其中包含一些作为 nuget 包发布的 Service Fabric 库项目 (.NET Standard 2.0)。解决方案 (.NET Core 2.0) 中的单元测试项目正在使用 xUnit。
我注意到在构建服务器上 运行 时测试花费了太多时间,与以前的构建 相比。
我使用 Reshaper/Visual Studio 或 powershell 脚本在我的本地机器上尝试了 运行 测试,它只用了不到 5 分钟:
$stopwatch = [system.diagnostics.stopwatch]::StartNew()
Get-ChildItem -recurse *tests.csproj | % {
dotnet test $_.FullName --no-build --no-restore;
}
$stopwatch.Stop()
Write-Host $stopwatch.Elapsed
但在 Azure Devops 中,单元测试任务需要超过 27 分钟才能完成!!!
这是构建 pipeline/unit 测试任务:
知道发生了什么吗?
在 Regression: dotnet test hangs for 15 minutes after test run completed on mac and linux 中找到了解决方案。
将以下参数添加到 dotnet build
任务的参数中就可以了:
-nodereuse:false
顺便说一句,生成代理是 Windows mac 海因斯,而不是上述问题中提到的 mac 或 linux。