我有一个 .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 分钟才能完成!!!
这是构建管道/单元测试任务:
知道发生了什么事吗?
最佳答案
在 Regression: dotnet test hangs for 15 minutes after test run completed on mac and linux 中找到解决方案.
将以下参数添加到 dotnet build
任务的参数中可以达到目的:
-nodereuse:false
顺便说一句,构建代理是 Windows 机器,而不是上述问题中提到的 mac 或 linux。
关于unit-testing - 单元测试在构建服务器上执行缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53779195/