在其他版本上,我看到以下内容,这就是我想要的。 此工作版本使用 VSTest
我试图获得代码覆盖率的构建正在使用
Npm@1
'run test-with-coverage'
生成覆盖率,并使用 PublishCodeCoverageResults@2
来发布 summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml'
。
我看到代码覆盖率选项卡包含正确的覆盖率数据,但在摘要屏幕上我只看到“开始”
我搜索过谷歌和必应,并与副驾驶讨论过。我将管道从 PublishCodeCoverageResults@1 升级到 PublishCodeCoverageResults@2。
我可以在我这边复制同样的内容。任务
PublishCodeCoverageResults@2
用于发布代码覆盖率结果而不是测试结果。
您可以添加PublishTestResults@2任务来发布测试结果。
确保您在
Npm@1
run test-with-coverage
任务中生成了测试结果(TEST-RESULTS.xml)。
例如,我的
npm test
任务的 package.json:
{
"name": "HelloWorld",
"private": true,
"version": "0.0.0",
"description": "Hello World",
"main": "server.js",
"author": {
"name": "",
"email": ""
},
...
"scripts": {
"test": "nyc --reporter=cobertura --reporter=html ./node_modules/.bin/mocha tests/**/*.js --reporter mocha-junit-reporter --reporter-options mochaFile=./TEST-RESULTS.xml"
}
}
yaml 示例:
- task: Npm@1
displayName: 'npm test'
inputs:
command: custom
customCommand: 'test'
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/TEST-RESULTS.xml'
testRunTitle: 'Test results for JavaScript'
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml'