在Linux上集成Postman与持续集成(CI)工具,核心步骤如下:
准备工具与环境
npm install -g newman。配置CI工具
junit格式报告)。pipeline {
agent any
stages {
stage('Run Postman Tests') {
steps {
sh 'npm install -g newman'
sh 'newman run "your_collection.json" --reporters cli,junit --reporter-junit-export report.xml'
}
}
stage('Publish Results') {
steps {
junit 'report.xml'
}
}
}
}
.github/workflows/目录创建postman.yml,定义自动化流程:name: Run Postman Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Newman
run: npm install -g newman
- name: Run Tests
run: newman run "your_collection.json" --reporters cli,junit --reporter-junit-export report.xml
- name: Upload Results
uses: actions/upload-artifact@v2
with:
name: postman-results
path: report.xml
集成与自动化
关键工具链:Postman(测试设计)→ Newman(命令行执行)→ CI工具(自动化调度与报告)。
参考来源: