在 Postman 与 Azure 管道集成期间无法从 newman 发布测试结果

时间:2021-05-12 09:03:48

标签: azure-devops postman azure-pipelines postman-collection-runner postman-testcase

我正在尝试使用 Newman for CI 将我的 Postman 集合与 Azure 管道集成并生成测试结果,我能够在 Azure Pipeline 中运行测试但无法发布结果。

以下是我遵循的步骤-

1.从 Postman 导入 postman collection.Json 和 environment.Json 到我的仓库中。

2.新建管道

3.新增代理

4.新增安装Newman任务

5.添加了第二个任务来运行我的测试

脚本-

newman run Staging_Tests.postman_collection.json -e staging.postman_environment.json --reporters cli,junit,htmlextra --reporter-junit-export Results\junitReport.xml --reporter-htmlextra-export Results\junitReport.html< /p>

以下是我为 API 测试提供的值- enter image description here

预期 - 根据脚本,它应该在工作目录中提供的文件夹中创建一个名为 Results 的目录,并且应该创建 junitReport.xml strong> 结果文件夹内的结果文件。

实际- 它正在执行我的测试,但未在工作目录路径中创建文件夹,我无法继续发布测试结果。

我在这里遗漏了什么吗?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

您的管道运行时没有任何错误,这表明该命令是正确的。结果文件夹已创建。

实际原因是结果在代理池的位置下,而不是在 azure devops 存储库上。它永远不会存储在云存储库下,并且在代理电脑的位置下,除非您再次将结果推回存储库。

所以我的功能是您应该添加发布构建工件任务以将结果从代理池获取到服务中。

另外,请将发布路径更改为$(Build.SourcesDirectory)

enter image description here

然后,点击pipeline下面的选项得到结果:

enter image description here