尽管测试成功,但 VSTS 测试任务失败
VSTS test task failed despite of success tests
即使在 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 Studio17\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 Studio17\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\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\s\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1\xxx.EndToEnd.Integration.Tests.deps.json to d:\a\a\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1\xxx.EndToEnd.Integration.Tests.deps.json
任务返回: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
的路径,在发布中,每个人工制品都会根据人工制品名称下载到特定位置。这是为了确保具有多个工件的版本不会意外覆盖彼此的文件。
测试 运行 在以下更改为 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)'
即使在 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 Studio17\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 Studio17\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\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\s\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1\xxx.EndToEnd.Integration.Tests.deps.json to d:\a\a\src\xxx.EndToEnd.Integration.Tests\bin\Release\netcoreapp2.1\xxx.EndToEnd.Integration.Tests.deps.json
任务返回: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
的路径,在发布中,每个人工制品都会根据人工制品名称下载到特定位置。这是为了确保具有多个工件的版本不会意外覆盖彼此的文件。
测试 运行 在以下更改为 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)'