在 Azure Devops 中发布测试结果任务
Publish Test Results task in Azure Devops
我是 运行 我在 TFS/AZureDevopsServer-2019 中的构建和发布管道,下面是 azure-pipeline.yml
中使用的 YAML
管道运行时不会生成分析
建立管道
如何根据“https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=trx%2Cyaml”我在我的管道中添加了以下任务
- task: Maven@3
inputs:
mavenPomFile: '$(System.DefaultWorkingDirectory)/maven/pom.xml'
goals: package
mavenAuthenticateFeed: true
sonarQubeRunAnalysis: true
publishJUnitResults: true
sqMavenPluginVersionChoice: 'latest'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
searchFolder: '$(System.DefaultWorkingDirectory)'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
codeCoverageToolOption: JaCoCo
流水线结果
2021-03-30T17:11:52.9179560Z ##[warning]No test result files matching **/TEST-*.xml were found.
错误消息表明没有匹配 **/TEST-*.xml 的测试结果文件。您需要检查您的管道中是否有测试任务,并查看运行测试任务后的日志,检查是否已生成测试文件。
此外,默认选项使用JUnit格式发布测试结果。 **/TEST-*.xml
搜索所有子目录中名称以 TEST-
开头的所有 XML 个文件。如果使用 VSTest 作为 testRunner,testResultsFiles 选项应更改为 **/TEST-*.trx
.
如果有人正在使用部署在 Windows 机器上的代理,这里有一个提示。我建议不要为测试结果路径指定 $(System.DefaultWorkingDirectory)
。测试运行器相对于当前工作目录创建 'test results' 个文件。例如,如果你是运行 junit,那么你可以指定--junit-directory /reports
,代理会在当前工作目录下创建一个/reports
文件夹,.xml
文件将放在/reports
。相反,指定 $(System.DefaultWorkingDirectory)/reports
会产生一些不良结果。
我是 运行 我在 TFS/AZureDevopsServer-2019 中的构建和发布管道,下面是 azure-pipeline.yml
中使用的 YAML管道运行时不会生成分析
建立管道
如何根据“https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=trx%2Cyaml”我在我的管道中添加了以下任务
- task: Maven@3
inputs:
mavenPomFile: '$(System.DefaultWorkingDirectory)/maven/pom.xml'
goals: package
mavenAuthenticateFeed: true
sonarQubeRunAnalysis: true
publishJUnitResults: true
sqMavenPluginVersionChoice: 'latest'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
searchFolder: '$(System.DefaultWorkingDirectory)'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
codeCoverageToolOption: JaCoCo
流水线结果
2021-03-30T17:11:52.9179560Z ##[warning]No test result files matching **/TEST-*.xml were found.
错误消息表明没有匹配 **/TEST-*.xml 的测试结果文件。您需要检查您的管道中是否有测试任务,并查看运行测试任务后的日志,检查是否已生成测试文件。
此外,默认选项使用JUnit格式发布测试结果。 **/TEST-*.xml
搜索所有子目录中名称以 TEST-
开头的所有 XML 个文件。如果使用 VSTest 作为 testRunner,testResultsFiles 选项应更改为 **/TEST-*.trx
.
如果有人正在使用部署在 Windows 机器上的代理,这里有一个提示。我建议不要为测试结果路径指定 $(System.DefaultWorkingDirectory)
。测试运行器相对于当前工作目录创建 'test results' 个文件。例如,如果你是运行 junit,那么你可以指定--junit-directory /reports
,代理会在当前工作目录下创建一个/reports
文件夹,.xml
文件将放在/reports
。相反,指定 $(System.DefaultWorkingDirectory)/reports
会产生一些不良结果。