API自动化测试与持续集成
目的 如何使用SuperTest测试框架,进行API测试 如何将API测试与构建工具结合 如何将API测试、构建工具与持续集成结合 ...
目的 如何使用SuperTest测试框架,进行API测试 如何将API测试与构建工具结合 如何将API测试、构建工具与持续集成结合 ...
Gulp Automate and enhance your workflow 用自动化构建工具增强你的工作流程! 官网:http://gulpjs.com/ 中文官网:http://www.gulpjs.com.cn/ 简体中文文档: https://github.com/lisposter/gulp-docs-zh-cn 安装npm install --global gulp 验证 ➜ Downloads gulp -v [15:59:38] CLI version 3.9.1 [15:59:38] Local version 3.9.1 ...
Jenkins In a nutshell, Jenkins is the leading open source automation server. Built with Java, it provides hundreds of plugins to support building, testing, deploying and automation for virtually any project Jenkins是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能。 ...
Header 定义 提供HTTP所需要的信息或发送的信息 HTTP header fields provide required information about the request or response, or about the object sent in the message body. ...
SuperTest SuperTest-API测试 Auth分类 Basic:基本身份认证,直接采用:用户名密码 基本用法 1 2 3 4 5 6 it('should receive a status code of 200 with login', function(done) { request(url) .get('/staging') .auth('the-username', 'the-password') .expect(200, done); }); Base64加密 1 .set("Authorization", "basic " + new Buffer("username:password").toString("base64")) Digest:摘要式身份认证 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 request.get('http://some.server.com/').auth('username', 'password', false); // or request.get('http://some.server.com/', { 'auth': { 'user': 'username', 'pass': 'password', 'sendImmediately': false } }); // or request.get('http://some.server.com/').auth(null, null, true, 'bearerToken'); // or request.get('http://some.server.com/', { 'auth': { 'bearer': 'bearerToken' } }); OAuth Authentication 例子 1 2 3 4 5 6 7 8 9 10 11 12 13 14 var OAuth = require('openauth'); var request = require('superagent'); require('superagent-openauth')(request); var oauth = new OAuth(consumerKey, consumerSecret, {...}); request.post('https://api.twitter.com/1.1/statuses/update.json') .sign(oauth, token, tokenSecret) .type('urlencoded') .send({status: 'hello world'}) .end(function(res) { console.log(res.status, res.body); }); OAuth 1 1 request.sign(oauth, token, secret); oauth: OAuth instance token: string access token secret: string access token secret ...
安装Mysql包 npm install mysql 调用 Mysql包 1 var mysql = require('mysql'); 数据库查询 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 var mysql = require('mysql'); var connection = mysql.createConnection({ host : '10.29.10.29', port : 3307, user : 'root', password : '', database : 'emall', //charset : 'UTF8_GENERAL_CI', debug : false }); connection.connect(); connection.query("use emall"); connection.query('select id from users', function(err,results) { if (err) { throw err; } }); connection.end(); 数据库插入 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 var mysql = require('mysql'); var connection = mysql.createConnection({ host : '10.29.10.29', port : 3307, user : 'root', password : '', database : 'emall', //charset : 'UTF8_GENERAL_CI', debug : false }); connection.connect(); connection.query("use emall"); var insertUser2 = "INSERT INTO `sms_verification_code` (`phone_number`, `code`) VALUES ('18392520000', '018227');"; connection.query(insertUser2,function(err,results,field){ if (err) { throw err; } }); connection.end(); API测试应用:Node.js 初始化数据 数据CRUD 获取部分无返回值的Post结果,如:查询创建用户后,获取用户的ID
什么是SuperTest The motivation with this module is to provide a high-level abstraction for testing HTTP, while still allowing you to drop down to the lower-level API provided by super-agent. 简单说明:用来测试HTTP请求,提供简单的super-agent来实现API请求 安装SuperTest npm安装 官网下载对应的操作系统版本-NPM,下载完成后,直接进行安装即可 cnpm,若翻墙网络比较慢或访问不了的话,可以尝试使用cnpm(国内的镜像)。CNPM SuperTest安装 npm install supertest --save-dev grunt安装 npm install -g grunt-cli 使用Grunt来管理和运行SuperTest Git Clone SuperTestDemo。此项目针对访问的URL的返回状态进行验证。 ...