如何将测试失败屏幕截图附加到 YAML 中的 Azure Pipeline 测试运行?

2023-12-30

我做了一些自动化测试(Testcafe)并将它们放在我的 VS 项目文件夹之一中,如图所示here https://i.stack.imgur.com/VFFfG.png.

1.失败时运行并截图的脚本:

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.用于复制文件和构建工件的脚本:

- task: CopyFiles@2
  inputs:
    sourceFolder: '$(Build.SourcesDirectory)'
    contents: '**/?(*.png)'
    targetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: '$(Build.ArtifactStagingDirectory)'
    artifactName: Saved failure screenshots

有没有什么方法可以将屏幕截图添加为步骤 2 中创建的测试运行的附件this https://i.stack.imgur.com/OzxUD.png使用Yaml?

目前可以在步骤 3 的工件结果中看到屏幕截图,但我希望将它们附加到测试运行中。


如果使用 JUnit 或 xUnit 报告格式,Azure DevOps 不支持附件(测试结果文件除外)。看在 Azure 文档中。

要使用“发布测试结果”任务将屏幕截图作为附件上传,您需要生成 NUnit 3.0 报告。您可能想看看这个社区为 NUnit 3.0 开发的 TestCafe 报告器:https://github.com/NickLargen/testcafe-reporter-nunit3 https://github.com/NickLargen/testcafe-reporter-nunit3

根据记者的文档,它可以包含视频和屏幕截图作为测试用例附件。请注意,由于该插件受社区支持,因此我们不能保证它在所有情况下都能按预期工作。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将测试失败屏幕截图附加到 YAML 中的 Azure Pipeline 测试运行? 的相关文章

随机推荐