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

标签 unit-testing .net-core azure-devops azure-service-fabric xunit

我有一个 .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 分钟才能完成!!!

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

Build pipeline tasks

知道发生了什么事吗?

最佳答案

Regression: dotnet test hangs for 15 minutes after test run completed on mac and linux 中找到解决方案.

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

-nodereuse:false

Build definition - dotnet build task

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

关于unit-testing - 单元测试在构建服务器上执行缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53779195/

相关文章:

c# - 如何在集成测试之间刷新 IAppCache

c# - 使用数据库作为从kafka消费的消息状态的存储是否正确?

azure - 有没有办法创建拉取请求,从 Azure Devops 中的 CD 管道在 RepoA 中从 RepoB 中创建新分支

visual-studio - 负载测试经过身份验证的用户

c# - 使用 ValueTask 等待单个 .NET 事件

azure - Terraform azuread 服务原则权限 权限

java - spring-boot-test spyBean 注释未注入(inject)依赖项

perl - 如何测试需要用户凭据的 CPAN 包

visual-studio-2008 - 在VS2008中,有什么方法可以将单元测试与集成测试分开吗?

c# - 如何更新 .NET Core 和 .NET Framework 应用程序之间共享的程序集