Jenkins+Postman+Newma+Xmysql之API全自动化测试

第一章 前期准备:各种安装配置介绍

①Postman安装及使用

②Newman 安装及使用

③Xmysql 安装及使用

④Jenkins安装及配置

1、postman 安装及使用

1.1、postman安装

1.2、postman使用
1.2.1、postman基础功能

在这里插入图片描述

1.2.2、常用断言

①验证本次请求的状态码,即验证本次请求是否能调通,或预设响应状态
tests[“Status code is 200”] = responseCode.code === 200;
tests[“Status code is 201”] = responseCode.code === 201;
②验证返回相应中的字段值
var jsonData = JSON.parse(responseBody);
tests[“Check respose value err_code”] = jsonData.err_code === 0;
③响应时间小于200ms
tests[‘Response time is less than 200ms‘] = responseTime < 200;
④response包含内容
tests[“Body matches string”] =responseBody.has(“string_you_want_to_search”);
⑤response等于预期内容
tests[“Body is correct”] = responseBody === “response_body_string”;

2、newman的安装及使用

2.1、newman的安装

newman是基于node.js测试框架,安装newman需要先安装node.js

2.1.1、安装node.js

下载对应你系统的Node.js版本:https://nodejs.org/en/download/
在这里插入图片描述
双击安装包,一路next直到finish,安装完成后,验证安装:
在这里插入图片描述

NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,常见的使用场景有以下几种:

允许用户从NPM服务器下载别人编写的第三方包到本地使用。
允许用户从NPM服务器下载并安装别人编写的命令行程序到本地使用。
允许用户将自己编写的包或命令行程序上传到NPM服务器供别人使用。
2.1.2、使用npm安装newman

npm install -g newman
在这里插入图片描述

2.2、newman的使用

newman run C:\Users\Administrator\Desktop\postman_test\AutoRyline_api.postman_collection.json --reporters cli,html,json,junit --reporter-json-export C:\Users\Administrator\Desktop\postman_test\jsonOut.json --reporter-junit-export C:\Users\Administrator\Desktop\postman_test\xmlOut.xml --reporter-html-export C:\Users\Administrator\Desktop\postman_test\html

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值