【发布时间】:2019-12-28 14:40:38
【问题描述】:
我正在使用 JUnit 来报告测试用例结果。根据我的理解,我们不能将屏幕截图或视频作为附件附加到 Azure 管道中的 JUnit 格式的“发布测试结果”任务生成的结果。
下面是我用来生成屏幕截图和视频的代码,而不是附加到测试结果报告中。
jobs:
- job: Cypress_e2e_tests
pool:
vmImage: 'windows-latest'
variables:
npm_config_cache: C:\Users\VssAdministrator\AppData\Local\npm-cache
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
- task: CacheBeta@1
inputs:
key: npm | $(Agent.OS) | package-lock.json
path: $(npm_config_cache)
restoreKeys: npm | $(Agent.OS) | package-lock.json
displayName: Cache NPM packages
- task: CacheBeta@1
inputs:
key: 'cypress | $(Agent.OS) | package-lock.json'
path: 'C:\Users\VssAdministrator\AppData\Local\Cypress'
restoreKeys: 'cypress | $(Agent.OS) | package-lock.json'
displayName: Cache cypress binary
- script: npm cache verify
displayName: 'NPM verify'
- script: npm ci
displayName: 'Install NPM dependencies'
- script: npm run cy:verify
displayName: 'Cypress verify'
- script: |
npx cypress run --browser chrome
displayName: 'Run Cypress tests'
workingDirectory: $(System.DefaultWorkingDirectory)
- task: PublishPipelineArtifact@0
displayName: 'Publish Screenshots (Cypress)'
condition: failed()
inputs:
artifactName: 'screenshots'
targetPath: '$(Build.SourcesDirectory)/cypress/screenshots'
- task: PublishPipelineArtifact@0
displayName: 'Publish Videos (Cypress)'
condition: failed()
inputs:
artifactName: 'videos'
targetPath: '$(Build.SourcesDirectory)/cypress/videos'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '*.xml'
failTaskOnFailedTests: true
testRunTitle: 'Cypress Test Results'
publishRunAttachments: true
condition: succeededOrFailed()
有没有办法将这些工件附加到测试结果中,而不是将这两个部分保留为单独的部分?
如果我们可以从节点项目生成带有附件的测试结果(我们可以使用可用于 .Net 项目的报告器附加文件,但我的工作项目完全基于节点),这对我来说将是最好的解决方案。
【问题讨论】:
-
我正在使用cypress进行UI测试,请看cypress支持的记者docs.cypress.io/guides/tooling/reporters.html#Reporter-Options
标签: node.js azure-devops azure-pipelines cypress