一、环境配置

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

newman 官方文档

newman github

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自动化测试应用的更多相关文章

  1. Postman+Newman+jenkins实现API自动化测试

    最近自己在学习用postman+newman+jenkins实现API自动化测试,这里做个回顾和记录.(此次是在windows上进行的环境搭建) 一.说明 1.大致思路:利用postman做接口调试所 ...

  2. Postman+newman+jenkins+git实战

    一.接口分类,流程,用例设计 接口分类: 外部接口:被测系统与外部其他系统之间的接口. 承保系统(被测系统),核算系统. 内部接口:被测系统内部各个子模块之间的接口. 承保系统(A模块,B模块) 测试 ...

  3. postman+newman+jenkins环境部署

    postman+newman+jenkins 环境部署 2017年4月27日 14:33 阅读 11 新浪博客 1.postman: http://itfish.net/article/59864.h ...

  4. Postman+Newman+Jenkins APItest自动化集成测试

    postman做接口测试简单易用很容易上手,但是接口越来越多,每次手动点击runner进行测试不灵活,最近就研究了下newman,利用newman实现接口的自动化测试,但是每次需要命令行操作也不方便, ...

  5. Newman+Jenkins实现接口自动化测试

    目录 一.是什么Newman 二.如何安装 三.如何使用 1.运行本地文件 2.运行在线文件 3.以node.js库运行 4.导出报告 四.命令行测试真实接口 1.导出collection文件 2.导 ...

  6. SpringBoot集成Swagger,Postman,newman,jenkins自动化测试.

    环境:Spring Boot,Swagger,gradle,Postman,newman,jenkins SpringBoot环境搭建. Swagger简介 Swagger 是一款RESTFUL接口的 ...

  7. Web API 持续集成:PostMan+Newman+Jenkins(图文讲解)

    本文由葡萄城技术团队于博客园原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 上篇文章我们已经完成了API测试工具选型,接下来是一系列周期性的开发 ...

  8. postman+newman+jenkins 接口自动化问题

    声明:个人原创,转载请注明 1.安装postman工具 下载地址:https://www.getpostman.com/点击下载,选择自己的系统,我的是windows系统,64位 2.postman ...

  9. postman+newman+jenkins

    1.postman: http://itfish.net/article/59864.html(网上参考资料) 1)安装(要用爬墙软件): 进入下面地址https://chrome.google.co ...

随机推荐

  1. laravel调用sql server存储过程并取得ReturnValue

    alter proc [dbo].[aaa](    @AgencyID int,--代理商ID    @AdminID int --结算操作人ID(管理员ID))asbegin    select ...

  2. 重新签名IOS .ipa文件 (包含第三方框架和插件)

    本文未经测试,初步看代码流程接近本人想法,留下作记录.Intoduction This code allow you to resign your own ipa assuming that you ...

  3. 如何设置select只读不可编辑且select的值可传递

    1. <select style="width:195px" name="role" id="role" onfocus=" ...

  4. 2-2 vue环境搭建以及vue-cli使用

    一.vue多页面应用文件引用 1.官网拷贝: <script src="https://cdn.jsdelivr.net/npm/vue"></script> ...

  5. 关于*** WARNING L15: MULTIPLE CALL TO SEGMENT

    编写51程序的时候,有时候会在主函数和中断函数里面调用同一个函数,如果正的出现这种情况,编译器会提出 这种警告: *** WARNING L15: MULTIPLE CALL TO SEGMENT(重 ...

  6. C 语言实现增量式PID

    一直以来,pid都是控制领域的经典算法,之前尝试理解了很久,但还是一知半解,总是不得要领,昨天模仿着别人的代码写了一个增量式pid的代码. 我的理解就是pid其实就是对你设置的预定参数进行跟踪.在控制 ...

  7. cmake practice一文中安装可执行文件的方法

    在学习cmake practice第四章中,第四章的任务如下 修改 Helloworld 支持安装在本节开头我们定义了本节的任务如下:1,为工程添加一个子目录 src,用来存储源代码;2,添加一个子目 ...

  8. HDU-2680 Choose the best route 单向边+反向dijkstra

    https://vjudge.net/problem/HDU-2680 题意:以起始点 终点 长度 给出一个图,已知可以从w个起点出发,求从任一起点到同一个终点s的最短路径.注意是单向边.m<1 ...

  9. 反面教材 构造构造 json 数据

    构造构造 json 数据 说说你们在项目中遇到过的最糟糕的代码 - V2EX https://www.v2ex.com/t/214099

  10. FW 构建OpenStack的高可用性(HA,High Availability)

    原文地址:http://blog.csdn.net/hilyoo/article/details/7704280 1.CAP理论 1) CAP 理论给出了3个基本要素: 一致性 ( Consisten ...