Postman + newman + jenkins 的API自动化测试应用
一、环境配置
Postman
postman 的具体使用可以参考另外一篇文章:postman 做接口测试之学习笔记
Newman
第一步,安装nodejs。
第二步,在nodejs命令行安装newman,即命令行输入如下命令:
npm install -g newman
jenkins
去官网(https://jenkins.io/index.html)下载jenkins
二、Postman + Newman + jenkins 的使用
1. 在postman中导出testcase 文件夹(即存各个接口的collection文件夹)和设置的环境变量文件。
如下所示,导出来的是个json 格式的文件


2. jenkins配置
注意:如果是安装在本地的Jenkins,要将jenkins开启,切换到jenkins.war 的路径下, 执行 java -jar jenkins.war 则可以开启了。

在jenkins上配置如下图,这个路径就是上面通过postman导出文件的路径。

剩下的就是jenkins的常规操作了,比如设置好邮箱后点击立即构建或者设置多久构建一次,这样自动化就跑起来了,等待自动化测试结束后我们就可以收到测试成功或者失败的测试报告邮件了(依赖于设置)。
通过上面这些步骤即可完成基于postman和Jenkins的自动化接口测试。
Newman的使用:
可以参考:
Newman - Running collections in the command line
Usage: newman [options]
Options:
-h, --help output usage information
-V, --version output the version number
-c, --collection [file] Specify a Postman collection as a JSON [file]
-u, --url [url] Specify a Postman collection as a [url]
-f, --folder [folder-name] Run a single folder from a collection. To be used with -c or -u
-e, --environment [file] Specify a Postman environment as a JSON [file]
--environment-url [url] Specify a Postman environment as a URL
-E, --exportEnvironment [file] Specify an output file to dump the Postman environment before exiting [file]
-d, --data [file] Specify a data file to use either json or csv
-g, --global [file] Specify a Postman globals file [file]
-G, --exportGlobals [file] Specify an output file to dump Globals before exiting [file]
-y, --delay [number] Specify a delay (in ms) between requests
-r, --requestTimeout [number] Specify a request timeout (in ms) for requests (Defaults to if not set)
-R, --avoidRedirects Prevents Newman from automatically following redirects
-s, --stopOnError Stops the runner with code= when a test case fails
-j, --noSummary Doesn't show the summary for each iteration
-n, --number [number] Define the number of iterations to run
-C, --noColor Disable colored output
-S, --noTestSymbols Disable symbols in test output and use PASS|FAIL instead
-k, --insecure Disable strict ssl
-l, --tls Use TLSv1
-N, --encoding [encoding-type] Specify an encoding for the response. Supported values are ascii,utf8,utf16le,ucs2,base64,binary,hex
-x, --exitCode Continue running tests even after a failure, but exit with code=. Incompatible with --stopOnError
-o, --outputFile [file] Path to file where output should be written [file]
-O, --outputFileVerbose [file] Path to file where full request and responses should be logged [file]
-t, --testReportFile [file] Path to file where results should be written as JUnit XML [file]
-i, --import [file] Import a Postman backup file, and save collections, environments, and globals [file] (Incompatible with any option except pretty)
-p, --pretty Enable pretty-print while saving imported collections, environments, and globals
-H, --html [file] Export a HTML report to a specified file [file]
-W, --whiteScreen Black text for white screen
-L, --recurseLimit [limit] Do not run recursive resolution more than [limit] times. Default = . Using will prevent any variable resolution
Newman is a command-line collection runner for Postman. You must specify a collection file or a collection URL to run newman
A collection file or URL is mandatory
Examples:
newman -c POSTMAN_COLLECTION
newman -u POSTMAN_COLLECTION -e POSTMAN_ENVIRONMENT
newman -c POSTMAN_COLLECTION -f SAMPLE_FOLDER
For more documentation, issues and examples head over to https://github.com/postmanlabs/newman
Postman + newman + jenkins 的API自动化测试应用的更多相关文章
- Postman+Newman+jenkins实现API自动化测试
最近自己在学习用postman+newman+jenkins实现API自动化测试,这里做个回顾和记录.(此次是在windows上进行的环境搭建) 一.说明 1.大致思路:利用postman做接口调试所 ...
- Postman+newman+jenkins+git实战
一.接口分类,流程,用例设计 接口分类: 外部接口:被测系统与外部其他系统之间的接口. 承保系统(被测系统),核算系统. 内部接口:被测系统内部各个子模块之间的接口. 承保系统(A模块,B模块) 测试 ...
- postman+newman+jenkins环境部署
postman+newman+jenkins 环境部署 2017年4月27日 14:33 阅读 11 新浪博客 1.postman: http://itfish.net/article/59864.h ...
- Postman+Newman+Jenkins APItest自动化集成测试
postman做接口测试简单易用很容易上手,但是接口越来越多,每次手动点击runner进行测试不灵活,最近就研究了下newman,利用newman实现接口的自动化测试,但是每次需要命令行操作也不方便, ...
- Newman+Jenkins实现接口自动化测试
目录 一.是什么Newman 二.如何安装 三.如何使用 1.运行本地文件 2.运行在线文件 3.以node.js库运行 4.导出报告 四.命令行测试真实接口 1.导出collection文件 2.导 ...
- SpringBoot集成Swagger,Postman,newman,jenkins自动化测试.
环境:Spring Boot,Swagger,gradle,Postman,newman,jenkins SpringBoot环境搭建. Swagger简介 Swagger 是一款RESTFUL接口的 ...
- Web API 持续集成:PostMan+Newman+Jenkins(图文讲解)
本文由葡萄城技术团队于博客园原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 上篇文章我们已经完成了API测试工具选型,接下来是一系列周期性的开发 ...
- postman+newman+jenkins 接口自动化问题
声明:个人原创,转载请注明 1.安装postman工具 下载地址:https://www.getpostman.com/点击下载,选择自己的系统,我的是windows系统,64位 2.postman ...
- postman+newman+jenkins
1.postman: http://itfish.net/article/59864.html(网上参考资料) 1)安装(要用爬墙软件): 进入下面地址https://chrome.google.co ...
随机推荐
- initializer element is not constant 问题
在Ubuntu下,比葫芦画瓢,写了一个程序,居然报错!!!! #include <stdio.h> ; int j = *(int *)(&i) ; int main (int a ...
- WPS 2019 去除自动升级 和 广告、及优化的点
搜狗输入法 里面的快捷键会影响wps的快捷键功能,需要关掉"搜狗输入法"里面的快捷键 1. 2.去除自动升级功能 3.去除 广告 WPS 2019 流程图(断网): 思维导图: 流 ...
- POJ 1117 Pairs of Integers
Pairs of Integers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4133 Accepted: 1062 Des ...
- [BeiJing2011]元素[贪心+线性基]
2460: [BeiJing2011]元素 Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 1245 Solved: 652[Submit][Stat ...
- WCF错误"The maximum message size quota for incoming messages (65536) has been exceeded."
错误原因有三:超过最大接受的传输值 1.webconfig或者 app.config 文件中的binding 节点进行 配置 maxBufferSize="2147483647" ...
- mysql max(),min()的优化
Select tables optimized away(选择表优化)
- 最简单,最实用的数据库CHM文档生成工具——DBCHM
DBCHM支持SqlServer/MySql/Oracle/PostgreSQL等数据库的表列批注维护管理. DBCHM有以下几个功能 表,列的批注可以编辑保存到数据库. 表,列的批注支持通过pdm文 ...
- pandas将DataFrame的列变成行索引
pandas提供了set_index方法可以将DataFrame的列(多列)变成行索引,通过reset_index方法可以将层次化索引的级别会被转移到列里面. 1.DataFrame的set_inde ...
- ubuntu怎么安装下载工具uget+aria2 for firefox
Windows下的下载工具--迅雷,之所以下载速度快,乃是它能搜索资源.为己所用,而不是仅仅从原始地址这单一资源处下载. Ubuntu下也有类似的工具,那就是aira2. aira2是一个命令行下载工 ...
- PAT-GPLT L1-039 - 古风排版 - [字符串输入输出]
题目链接:https://www.patest.cn/contests/gplt/L1-039 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standar ...