【发布时间】:2021-02-27 12:24:52
【问题描述】:
我使用 PublishTestResults 任务创建了以下 YAML 文件,以在 Azure DevOps 门户中显示 mocha 测试结果
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.14.1'
displayName: 'Install Node.js'
- script: |
npm install
mocha test --reporter mocha-junit-reporter
npm test
displayName: 'npm install and test'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '**/TEST-RESULTS.xml'
- task: ArchiveFiles@2
displayName: 'Archive $(System.DefaultWorkingDirectory)'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveFile: '$(Build.ArtifactStagingDirectory)/node.zip'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
但每当我运行构建时,我都会收到以下警告
"No test result files matching **/TEST-RESULTS.xml were found."
主要目的是在仪表板或测试选项卡中单独显示摩卡测试结果。这样我们就不必在构建过程中检查测试任务来查看测试结果了。
【问题讨论】:
-
当您在本地运行这些测试时,您认为它会创建名为
TEST-RESULTS.xml的测试结果文件吗? -
是的,它会在我的本地创建一个文件 test-results.xml
-
嗨@vigneshramesh,PublishTestResults 任务默认搜索路径是$(System.DefaultWorkingDirectory),在下一个任务中,我们可以看到您归档了根文件夹$(System.DefaultWorkingDirectory),请检查 node.zip 文件并确保它包含文件 TEST-RESULTS.xml?请检查它,然后在这里分享结果。
-
嗨@vigneshramesh,刚刚检查一下这个问题现在是否仍然阻止你?这个问题有什么更新吗?
标签: node.js junit azure-devops mocha.js