节点模块newman可用于执行Postman集合。请参阅以下程序包。json文件。这里,我们正在
unit\u测试
文件夹使用newman,还定义了newman依赖关系。
包裹json
{
"name": "postman-newman-jenkins",
"version": "1.0.0",
"description": "My Test Project",
"directories": {
"tests": "tests"
},
"scripts": {
"newman-tests": "newman run unit_tests/my-collection.postman_collection.json --reporters cli,junit --reporter-junit-export newman.xml --insecure"
},
"author": "Test Author",
"dependencies": {
"newman": "^3.5.2"
}
}
以下是Jenkinsfile的内容。我们正在使用NPM安装依赖项并执行测试。
詹金斯档案
pipeline {
agent { label 'LinuxSlave' }
stages {
stage ('Checkout') {
steps {
checkout scm
}
}
stage('Test'){
steps {
sh 'npm install'
sh 'npm run newman-tests'
junit 'newman.xml'
}
}
}
}