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 ...
随机推荐
- EGL 1.0 学习笔记
http://hi.baidu.com/leo_xxx/item/b01b1fc29abff355ac00ef5c 基本概念 EGL是OpenGL ES与本地Window系统之间的桥梁.EGL创建渲染 ...
- Android MediaScanner
一.MediaScanner 的使用 1)Intent.ACTION_MEDIA_SCANNER_SCAN_FILE:扫描指定文件 public void scanFileAsync(Context ...
- dhroid - NetJSONAdapter 网络化的adapter
关于adapter 我想对于大家来说已经不陌生了,基本应用都会用的很多,不知道现在你是不是还是按一定的套路写很多代码去实现adapter我想大多数人还是写个adapter继承自baseadapter ...
- FileStream实现多线程断点续传(已封装)
处理文件分片 处理缺失的分片文件 合并分片文件 MD5验证文件 using System; using System.Collections.Generic; using System.IO; usi ...
- zTree实现节点修改的实时刷新
一.应用场景 在实际应用中会遇到动态操作树各节点的需求,在增加树节点后如何实时动态刷新树就十分有必要了. 二.项目实践 比如要在test1234节点下新建子节点,首先要选中test1234节点,添 ...
- POJ-2018 Best Cow Fences(二分加DP)
Best Cow Fences Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10174 Accepted: 3294 Desc ...
- 视觉slam十四讲开源库安装教程
目录 前言 1.Eigen线性代数库的安装 2.Sophus李代数库的安装 3.OpenCV计算机视觉库的安装 4.PCL点云库的安装 5.Ceres非线性优化库的安装 6.G2O图优化库的安装 7. ...
- HDFS文件系统的JAVA-API操作(一)
使用java.net.URL访问HDFS文件系统 HDFS的API使用说明: 1.如果要访问HDFS,HDFS客户端必须有一份HDFS的配置文件 也就是hdfs-site.xml,从而读取Nameno ...
- hihocoder 1320 - 压缩字符串 - [hiho一下160周]
这道题目可以说是一道非常好非常一颗赛艇的DP题了. 需要注意的是,其中情形3),字符串必然能完全转化为 N(str)形式,如果有N(str1)M(str2)等等另外样式,应该首先使用拼接形式对其进行划 ...
- JDBC及Filter
JNDI容器:Java Naming Directory Interface,java命名目录接口EJB:javaEE服务器端组件模型,Enterprise JavaBean,设计目标与核心应用是建立 ...