如何从Azuredevops的自动化测试中获得结果

时间:2019-10-07 17:59:50

标签: c# .net azure-devops continuous-integration

我一直试图从构建管道中检索自动化测试结果。 这里有人可以帮我弄清楚吗?

这是我的构建管道: Build pipeline

我将VSTEST设置为默认值:

steps:
- task: VSTest@2
  displayName: 'VsTest - testAssemblies'
  inputs:
    runOnlyImpactedTests: false
    rerunFailedTests: false

还将“发布测试结果”设置为默认值:

steps:
- task: PublishTestResults@2
  displayName: 'Publish Test Results **/TEST-*.xml'
  inputs:
    testResultsFormat: VSTest

最后,我试图以松弛状态发布测试结果(但我不知道如何获取所需的数据)。

接下来,您可以看到构建的摘要: enter image description here

然后是POST SLACK通知的文字:

#Your build pipeline references an undefined variable named ‘date:yyyyMMdd’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

#Your build pipeline references an undefined variable named ‘rev:.r’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972



steps:

- task: kasunkodagoda.slack-notification.slack-notification-task.SlackNotification@5

  displayName: 'Post Slack Notification'

  inputs:

    SlackApiToken: 'xoxp-I_HIDE_IT_BECAUSE_IT_IS_SECRET'

    Channel: '#devops_ci'

    Message: 'A new build is available $(date:yyyyMMdd)$(rev:.r)'

    UseVariableForMessage: true

    AuthorName: 'Continuous Integration'

    AuthorLink: 'https://I_HIDE_IT_BECAUSE_IT_IS_SECRET.visualstudio.com/SHIVA/_build?definitionId=1'

    PreText: 'Attachment Pre-Text'

    Text: 'Attachment Text'

非常感谢您。

1 个答案:

答案 0 :(得分:1)

尽管create a webhook可以帮助您将构建状态发布到松弛状态,但是其状态消息仅用于构建,而不是显示其测试任务结果。

作为您在注释中描述的内容,您希望在松弛状态下发布诸如number_of_test_ok / number_of_total_tests之类的消息。恐怕没有这种现成的功能可以帮助您实现这一目标。

此外,同意@BradleyDotNET,没有预定义变量存储消息(如测试计数)。因为获取这些消息需要从.trx文件分析属性。这也是汇总显示测试消息的编译逻辑。参见:Result mapping

在我们的官方论坛上提出了这样的功能建议:Publish test results summary to slack channel。您可以在此处进行投票和评论,以使其具有广泛的社区影响力,也将改善Azure Devops的体验。因此,我们的产品小组将考虑将此功能纳入我们的开发路线图。

相关问题