尽管测试成功,但VSTS测试任务仍然失败 [英] VSTS test task failed despite of success tests

查看:167
本文介绍了尽管测试成功,但VSTS测试任务仍然失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使在VsTest任务下通过了所有测试,我也仍然遇到错误.

I get below error even after all the test passed under VsTest task.

2019-04-04T10:22:14.3913769Z Unable to find d:\a\r1\a\xxx\e2e\bin\Release\netcoreapp2.1\testhost.dll. Please publish your test project and retry.
2019-04-04T10:22:15.1564640Z Results File: d:\a\r1\a\TestResults\VssAdministrator_fv-az153_2019-04-04_10_22_13.trx
2019-04-04T10:22:15.1606430Z 
2019-04-04T10:22:15.1607111Z Test Run Aborted.
2019-04-04T10:22:15.1607372Z Total tests: Unknown. Passed: 6. Failed: 0. Skipped: 0.
2019-04-04T10:22:15.1607627Z Test execution time: 36.3008 Seconds
2019-04-04T10:22:15.3788506Z ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
2019-04-04T10:22:15.3917110Z ##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1
2019-04-04T10:22:15.8355860Z ##[error]VsTest task failed

当我在本地尝试以下但没有错误时:

When I tried locally with below but no errors:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe C:\xxx\src\xxx.EndToEnd.Integration.Tests\bin\Debug\netcoreapp2.1\xxx.EndToEnd.Integration.Tests.dll /logger:trx 2>error.txt

我也尝试过此解决方案,但是没有运气.

I tried this solution as well, but no luck.

build.yaml

- task: CopyFiles@2
      displayName: "Copy Files to: $(Build.ArtifactStagingDirectory)"
      inputs: 
        contents: '$(Build.SourcesDirectory)/src/xxx.EndToEnd.Integration.Tests/**'
        targetFolder: $(Build.ArtifactStagingDirectory)

    - task: DotNetCoreCLI@2
      displayName: "dotnet e2e tests"
      inputs:
        command: publish
        publishWebProjects: false
        projects: '**/*.csproj'
        arguments: --output $(Build.ArtifactStagingDirectory)/src/xxx.EndToEnd.Integration.Tests
        zipAfterPublish: false

    - task: PublishBuildArtifacts@1
      displayName: "Publish End-to-End Tests"
      inputs: 
        artifactName: e2e
        PathtoPublish: '$(Build.ArtifactStagingDirectory)/src/xxx.EndToEnd.Integration.Tests'

我在下面的日志中注意到它们的路径有所不同(即发布管道-d:\a\r1\a\EstimationCore\e2e\xxx.EndToEnd.Integration.Tests构建管道- d:\a\1\a\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1

I noticed below in logs which has difference in paths (i.e. Release pipeline - d:\a\r1\a\EstimationCore\e2e\xxx.EndToEnd.Integration.Tests and Build pipeline -d:\a\1\a\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1

完整日志:

Release pipeline - Download artifact - EstimationCore - e2e
2019-04-07T09:05:10.8843174Z Downloaded e2e/xxx.EndToEnd.Integration.Tests/xxx.EndToEnd.Integration.Tests.deps.json to d:\a\r1\a\EstimationCore\e2e\xxx.EndToEnd.Integration.Tests\xxx.EndToEnd.Integration.Tests.deps.json

Build pipeline - Copy Files to: $(Build.ArtifactStagingDirectory)
Copying d:\a\1\s\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1\xxx.EndToEnd.Integration.Tests.deps.json to d:\a\1\a\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1\xxx.EndToEnd.Integration.Tests.deps.json

推荐答案

在对build.yaml进行以下更改后,测试成功运行.因此,您可以看到问题出在文件夹路径上

The tests ran successfully after the below changes to the build.yaml. So as you can see the issue was with the folder paths

task: CopyFiles@2不必要

- task: DotNetCoreCLI@2
      displayName: "dotnet e2e tests"
      inputs:
        command: publish
        publishWebProjects: false
        projects: '**/**/*.EndToEnd.Integration.Tests.csproj'
        arguments: --output $(Build.ArtifactStagingDirectory)
        zipAfterPublish: false

    - task: PublishBuildArtifacts@1
      displayName: "Publish End-to-End Tests"
      inputs: 
        artifactName: e2e
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'

这篇关于尽管测试成功,但VSTS测试任务仍然失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆