【问题标题】:Azure DevOps nunit test execution very slowAzure DevOps nunit 测试执行非常慢
【发布时间】:2020-10-01 11:18:44
【问题描述】:

我们正在将 DevOps 迁移到 Azure。我们正在经历使用 nunit 运行单元测试所需的时间显着增加。主机配置了远程代理,作业在这台机器上执行。测试在用 C# 编写的 .Net 框架解决方案上进行。

以前,我们将 Jenkins 用于 DevOps,并在同一台计算机上使用代理。测试工作要快得多。在 Jenkins 上,这项工作大约在 2 小时 30 分钟内完成。在 Azure DevOps 中,它在 5 小时后失败(这是配置的超时),所以甚至没有完成。

这是 Azure 中的 yaml 代码:

  - task: VSTest@2
    timeoutInMinutes: 600
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: '*.Test*.dll'
      searchFolder: '$(System.DefaultWorkingDirectory)/$(buildConfiguration)'
      codeCoverageEnabled: false
      platform: 'Any CPU'
      configuration: '$(buildConfiguration)'
      rerunFailedTests: false
      pathtoCustomTestAdapters: 'Solution/packages/NUnit3TestAdapter.3.12.0/build/net35'
      minimumExpectedTests: 1000
      runInParallel: true
      failOnMinTestsNotRun: true
      resultsFolder: 'testResults'
    continueOnError: true

在 Jenkins 上,作业是这样配置的:

stage('Testing'){
    when{
        expression{ params.runTests == true}
    }
    steps{
        bat "MSBuild.exe Solution\\Vibrosight.sln /p:Configuration=Debug /p:Platform=\"Any CPU\" /t:Rebuild /maxcpucount:4"
        bat returnStatus:false, script: '''nunit3-console.exe Solution\\Vibrosight.sln --config=Debug --agents=1 --result=TestResult.xml;format=nunit2 --timeout=900000 --workers=1
        exit 0'''               
        nunit testResultsPattern: 'TestResult.xml'              
    }
}

有人对我如何改进 Azure DevOps 上的 nunit 测试执行有一些建议吗?

非常感谢

【问题讨论】:

  • 一个显着的变化是您已经从按顺序运行测试程序集变为并行运行它们。如果您的测试运行未在 Azure 上完成,是否有任何可能导致不同测试程序集之间的死锁?启用diagnosticsEnabled 选项可能值得,以查看特定测试是否导致问题。
  • 非常感谢克里斯的回答。我发现一项测试确实被阻止了。带有 ok 按钮等待用户确认的弹出对话框阻止了测试。我不知道为什么詹金斯不是这样。无论如何,我忽略了测试,然后一切都像以前一样在 2 小时 30 分钟内通过。我让你知道 diagnosticsEnabled,这对下次很有帮助。谢谢。

标签: azure nunit devops


【解决方案1】:

如上所述,测试阻止了执行。忽略此测试后,运行正常并且几乎与以前相同。再次感谢 Chris 您的提示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多