问题描述
我做了一些自动化测试 (Testcafe) 并将它们放在我的 VS 项目文件夹之一中,如图所示这里.
I have made some automated test (Testcafe) and put them together in one of my VS projects folder as shownhere.
1. 运行失败并截图的脚本:
1.Script to run and take screenshots on failure:
script: testcafe chrome **/Tests/**/* -S -s takeOnFails=true --reporter spec,xunit:report.xml
displayName: Run tests and save screenshots
continueOnError: true
2.发布脚本:
- task: PublishTestResults@2
displayName: Publish test results
continueOnError: true
inputs:
testResultsFiles: '**/report.xml'
searchFolder: $(System.DefaultWorkingDirectory)
testResultsFormat: 'JUnit'
publishRunAttachments: true
testRunTitle: "Task Results"
failTaskOnFailedTests: false
3.用于复制文件和构建工件的脚本:
3.Script for copying files and build artifact:
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)'
contents: '**/?(*.png)'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: Saved failure screenshots
有什么方法可以在第 2 步创建的测试运行中添加屏幕截图作为附件,例如这个使用 Yaml?
Is there any way to add screenshots as attachment on test run created at step 2 likethis using Yaml?
目前可以在第 3 步的工件结果中看到屏幕截图,但我希望将它们附加到测试运行中.
Currently screenshots can be seen at artifact result from step 3 but I want them to be attached to test run.
推荐答案
如果使用 JUnit 或 xUnit 报告格式,Azure DevOps 不支持附件(测试结果文件除外).请参阅 Azure 文档中的捕获屏幕截图.
Azure DevOps does not support attachments (other than the test result file) if you use the JUnit or xUnit report format. See Capture Screenshots in the Azure docs.
要将屏幕截图作为发布测试结果任务的附件上传,您需要生成 NUnit 3.0 报告.你可能想看看这个社区为 NUnit 3.0 开发的 TestCafe 报告器:https://github.com/NickLargen/testcafe-reporter-nunit3
To upload screenshots as attachments with the Publish Test Results task, you need to generate an NUnit 3.0 report. You may want to take a look at this community-developed TestCafe reporter for NUnit 3.0: https://github.com/NickLargen/testcafe-reporter-nunit3
根据记者的文档,它可以包括视频和屏幕截图作为测试用例附件.请注意,由于社区支持此插件,我们不能保证它在所有情况下都能按预期工作.
According to the reporter's documentation, it can include videos and screenshots as test case attachments. Please note that since this plugin is supported by the community, we cannot promise that it will work as expected in all cases.
这篇关于如何将测试失败屏幕截图附加到 YAML 中的 Azure Pipeline 测试运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!