即使在VsTest
任务下通过了所有测试,我仍然遇到错误。
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
当我在本地尝试以下但没有错误时:
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
我也尝试过this解决方案,但是没有运气。
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
完整日志:
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
答案 0 :(得分:2)
任务返回:Test Run Aborted.
因此,并非所有测试都已执行。这是可能的原因:
Unable to find d:\a\r1\a\xxx\e2e\bin\Release\netcoreapp2.1\testhost.dll. Please publish your test project and retry.
我很高兴这导致测试执行失败:)。
该错误提示您应该在运行测试之前发布测试项目,以确保将所有依赖项都复制到输出目录中。
您尚未共享其余的工作流程,但是我冒犯错误中提到的内容很有意义。
确保所有路径均正确,以便找到正确的文件。在构建中,您可以控制发布中的--output
中的路径,每个人工制品都会根据人工制品名称下载到特定位置。这是为了确保具有多个伪像的发行版本不会意外覆盖彼此的文件。
答案 1 :(得分:0)
在对build.yaml
进行以下更改之后,测试成功运行。因此,您可以看到问题出在文件夹路径上
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)'