我使用Git存储库中的文件通过Newman运行Postman测试。这很好用。我的问题是,我有多组测试,每组测试都有自己的Jenkins任务,该任务在构建成功时触发。我尽量不使用多个git存储库来托管这些文件。
使用如下所示的package.json文件运行测试:
{
"name": "postmanfiles",
"version": "1.0.0",
"description": "project to store postman collection",
"main": "index.js",
"scripts": { "api-tests": "newman run --verbose --timeout 8000000 --reporters 'cli,testrail' 'SearchAPI.postman_collection.json' -e 'My_Environment.postman_environment.json'" },
"keywords": [ "Postman", "CI" ],
"author": "Joe Smith",
"license": "ISC",
"dependencies": { "newman": "^6.14.10"
}
我有多个Postman集合,例如,对于每组测试,都有‘SearchAPI.postman_collection tion.json’、‘ModifyAPI.postman_ collections tion.json’等。
为了不使用多个Git repos进行这些测试,我需要在一个存储库中使用多个package.json文件,因为我有五个不同的Postman集合要运行。每个Jenkins作业都会触发单独的构建。一个简单的方法是在一个Git存储库中有五个不同的、唯一命名的package.json文件。
但是我能做到这一点吗?如果我能做到,我该如何做到呢?
或者有一种更简单的方法可以做到这一点?
发布于 2021-03-29 17:55:09
据我所知,你不能。这就是为什么我们使用像Grunt/Gulp或Webpack这样的工具来完成复杂的构建工作流程。
发布于 2021-03-29 19:20:11
我通过在package.json中指定多个测试,然后在存储库中使用唯一的Jenkins脚本,每组测试一个脚本,从而实现了这一点。
"scripts": {
"api-tests": "newman run --verbose --timeout 8000000 --reporters 'cli' 'SearchAPI.postman_collection.json' -e 'CTV_Environment.postman_environment.json'",
"site-tests": "newman run --verbose --timeout 8000000 --reporters 'cli' 'SiteAPI.postman_collection.json' -e 'CTV_Environment.postman_environment.json'"
},
https://stackoverflow.com/questions/66858984
复制相似问题