找不到要发布“/home/vsts/work/1/s/portal/test-result.xml”的结果
No Result Found to Publish '/home/vsts/work/1/s/portal/test-result.xml'
我正在尝试设置任务 PublishTestResults@2 so it shows xunit style mocha test results in azure devlops pipeline test tab。
不幸的是,我遇到了一个错误:
Obtained XUnit Test Run Start Date: 2020-09-18T12:48:36.0000000Z and Completed Date: 2020-09-18T12:48:36.0470000Z
No Result Found to Publish '/home/vsts/work/1/s/portal/test-result.xml'.
Async Command Start: Publish test results
Async Command End: Publish test results
Finishing: Publish Test Results
配置有问题吗?也许我遗漏了一些额外的东西。
我之前使用过 mocha-junit-reporter 但由于某些原因它无法显示 xml 文件中的所有测试用例。它只显示了 1800 多个测试用例中的 112 个。
配置如下
package.json
{
"scripts": {
"test:pipeline": "mocha --reporter mocha-xunit-reporter --reporter-options \"addTags=true,assemblyName=Tests,mochaFile=./test-result.xml\" --require test-setup.js --recursive ./ClientApp/**/*.spec.ts*",
},
"dependencies": {
"mocha": "6.2.0",
"mocha-xunit-reporter": "2.2.0",
}
}
yaml 文件
- job: build_web
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Npm@1
displayName: 'Restore NPM packages'
inputs:
command: 'install'
workingDir: './portal'
- task: Npm@1
displayName: 'Run Unit Tests'
inputs:
command: 'custom'
workingDir: './portal'
customCommand: 'run test:pipeline'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunTitle: 'Mocha Tests'
testResultsFormat: 'xUnit'
testResultsFiles: '**/test-*.xml'
感谢帮助
--编辑
Run Unit Tests
步骤正在创建文件,如果找不到它我会收到错误消息:
##[warning]No test result files matching **/test-*.xml were found.
那是我在摆弄 yaml 时发生的。
步骤日志。
Starting: Run Unit Tests
==============================================================================
Task : npm
Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version : 1.175.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/usr/local/bin/npm --version
6.14.8
/usr/local/bin/npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v12.18.3 linux x64"
; environment configs
userconfig = "/home/vsts/work/1/npm/722.npmrc"
; node bin location = /usr/local/bin/node
; cwd = /home/vsts/work/1/s/portal
; HOME = /home/vsts
; "npm config ls -l" to show all defaults.
/usr/local/bin/npm run test:pipeline
> portal@1.0.0 test:pipeline /home/vsts/work/1/s/portal
> mocha --reporter mocha-xunit-reporter --reporter-options "addTags=true,assemblyName=Portal Tests,mochaFile=test-result.xml" --require test-setup.js --recursive ./ClientApp/**/*.spec.ts*
Finishing: Run Unit Tests
我将 vmImage 切换为 windows,将 mocha reporter 切换为 mocha-junit-reporter,现在运行正常。
换图后懒得再看其他记者
这是区别。
- job: build_web
pool:
vmImage: 'windows-2019'
...
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunTitle: 'Mocha Tests'
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-*.xml'
"scripts": {
"test:pipeline": "mocha --reporter mocha-junit-reporter --reporter-options mochaFile=./test-result.xml --timeout 60000 --require test-setup.js --recursive ./ClientApp/**/*.spec.ts*",
},
"dependencies": {
"mocha": "6.2.0",
"mocha-junit-reporter": "1.23.1",
}
}
我正在尝试设置任务 PublishTestResults@2 so it shows xunit style mocha test results in azure devlops pipeline test tab。
不幸的是,我遇到了一个错误:
Obtained XUnit Test Run Start Date: 2020-09-18T12:48:36.0000000Z and Completed Date: 2020-09-18T12:48:36.0470000Z
No Result Found to Publish '/home/vsts/work/1/s/portal/test-result.xml'.
Async Command Start: Publish test results
Async Command End: Publish test results
Finishing: Publish Test Results
配置有问题吗?也许我遗漏了一些额外的东西。
我之前使用过 mocha-junit-reporter 但由于某些原因它无法显示 xml 文件中的所有测试用例。它只显示了 1800 多个测试用例中的 112 个。
配置如下
package.json
{
"scripts": {
"test:pipeline": "mocha --reporter mocha-xunit-reporter --reporter-options \"addTags=true,assemblyName=Tests,mochaFile=./test-result.xml\" --require test-setup.js --recursive ./ClientApp/**/*.spec.ts*",
},
"dependencies": {
"mocha": "6.2.0",
"mocha-xunit-reporter": "2.2.0",
}
}
yaml 文件
- job: build_web
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Npm@1
displayName: 'Restore NPM packages'
inputs:
command: 'install'
workingDir: './portal'
- task: Npm@1
displayName: 'Run Unit Tests'
inputs:
command: 'custom'
workingDir: './portal'
customCommand: 'run test:pipeline'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunTitle: 'Mocha Tests'
testResultsFormat: 'xUnit'
testResultsFiles: '**/test-*.xml'
感谢帮助
--编辑
Run Unit Tests
步骤正在创建文件,如果找不到它我会收到错误消息:
##[warning]No test result files matching **/test-*.xml were found.
那是我在摆弄 yaml 时发生的。
步骤日志。
Starting: Run Unit Tests
==============================================================================
Task : npm
Description : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version : 1.175.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
/usr/local/bin/npm --version
6.14.8
/usr/local/bin/npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v12.18.3 linux x64"
; environment configs
userconfig = "/home/vsts/work/1/npm/722.npmrc"
; node bin location = /usr/local/bin/node
; cwd = /home/vsts/work/1/s/portal
; HOME = /home/vsts
; "npm config ls -l" to show all defaults.
/usr/local/bin/npm run test:pipeline
> portal@1.0.0 test:pipeline /home/vsts/work/1/s/portal
> mocha --reporter mocha-xunit-reporter --reporter-options "addTags=true,assemblyName=Portal Tests,mochaFile=test-result.xml" --require test-setup.js --recursive ./ClientApp/**/*.spec.ts*
Finishing: Run Unit Tests
我将 vmImage 切换为 windows,将 mocha reporter 切换为 mocha-junit-reporter,现在运行正常。
换图后懒得再看其他记者
这是区别。
- job: build_web
pool:
vmImage: 'windows-2019'
...
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunTitle: 'Mocha Tests'
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-*.xml'
"scripts": {
"test:pipeline": "mocha --reporter mocha-junit-reporter --reporter-options mochaFile=./test-result.xml --timeout 60000 --require test-setup.js --recursive ./ClientApp/**/*.spec.ts*",
},
"dependencies": {
"mocha": "6.2.0",
"mocha-junit-reporter": "1.23.1",
}
}