单元测试在构建服务器上执行缓慢

Rui*_*mba 3 unit-testing xunit .net-core azure-service-fabric azure-devops

我有一个.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
Run Code Online (Sandbox Code Playgroud)

但是在Azure Devops中,单元测试任务需要花费超过27分钟才能完成!!!

这是构建管道/单元测试任务:

建立管道任务

有什么想法吗?

Rui*_*mba 5

Regression中找到了解决方案:在Mac和Linux上完成测试运行后,dotnet测试挂起15分钟

将以下参数添加到dotnet build任务的参数即可达到目的:

-nodereuse:假

构建定义-dotnet构建任务

顺便说一句,构建代理是Windows计算机,而不是上述问题中提到的mac或linux。