VSTS test task failed despite of success tests

此生再无相见时 提交于 2019-12-16 18:04:45

问题


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'

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

Full log :

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

回答1:


The task returned with: Test Run Aborted. Thus not all tests were executed. And this is the probable cause:

Unable to find d:\a\r1\a\xxx\e2e\bin\Release\netcoreapp2.1\testhost.dll. Please publish your test project and retry.

I'm happy this causes the test execution to fail :).

The error mentions you should publish your test project prior to running the tests to ensure all dependencies are copied into the output directory.

You haven't shared the rest of your workflow, but I'd hazard following the thing mentioned in the error makes a lot of sense.

Make sure all the paths are correct so that the right files are found. In build you take control over the paths through the --output in release each artefact is downloaded to a specific location based on the artefact name. This is to ensure releases with multiple artefacts don't overwrite each other's files accidentally.




回答2:


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 is not necessary

- 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)'


来源:https://stackoverflow.com/questions/55514528/vsts-test-task-failed-despite-of-success-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!