与你相遇好幸运,mocha接口测试
var rest = require('restler');
var assert = require("assert");
var systemID;
var userID;
console.log('--------------------------------------');
console.log('SYSTEM TEST START ..');
console.log('--------------------------------------');
describe('system',function(){
it('增加',function(done){
rest
.post('http://127.0.0.1:1337/system/',{data:{system:'test',uri:'http://test.com'}})
.on('complete', function(result) {
"use strict";
assert.equal('test',result.result.system);
assert.equal('http://test.com',result.result.uri);
systemID = result.result.id;
done();
});
});
it('修改',function(done){
rest
.put('http://127.0.0.1:1337/system/'+systemID,{data:{system:'test',uri:'http://test2.com'}})
.on('complete', function(result) {
"use strict";
//console.log(result);
assert.equal('test',result.result.system);
assert.equal('http://test2.com',result.result.uri);
done();
});
});
it('查看',function(done){
rest
.get('http://127.0.0.1:1337/system/')
.on('complete', function(result) {
"use strict";
assert.equal('test',result.result[result.result.length - 1].system);
assert.equal('http://test2.com',result.result[result.result.length - 1].uri);
done();
});
});
it('删除',function(done){
rest
.del('http://127.0.0.1:1337/system/'+systemID)
.on('complete', function(result) {
"use strict";
assert.equal('test',result.result.system);
assert.equal('http://test2.com',result.result.uri);
done();
});
});
});
describe('user',function(){
it('增加',function(done){
rest
.post('http://127.0.0.1:1337/user/',{data:{email:'test@test.com',passwd:'test'}})
.on('complete', function(result) {
"use strict";
assert.equal('test@test.com',result.result.email);
userID = result.result.id;
done();
});
});
it('修改',function(done){
rest
.put('http://127.0.0.1:1337/user/'+userID,{data:{email:'test2@test.com'}})
.on('complete', function(result) {
"use strict";
//console.log(result);
assert.equal('test2@test.com',result.result.email);
done();
});
});
it('查看',function(done){
rest
.get('http://127.0.0.1:1337/user/')
.on('complete', function(result) {
"use strict";
assert.equal('test2@test.com',result.result[result.result.length - 1].email);
done();
});
});
it('删除',function(done){
rest
.del('http://127.0.0.1:1337/user/'+userID)
.on('complete', function(result) {
"use strict";
assert.equal('test2@test.com',result.result.email);
done();
});
});
});
与你相遇好幸运,mocha接口测试的更多相关文章
- nodejs+supertest+mocha 接口测试环境搭建
系统接口自动化测试 该框架用于对系统的接口自动化测试(nodejs+supertest+mocha)Homebrew 安装: ruby -e "$(curl -fsSL {+}https:/ ...
- 与你相遇好幸运,服务器node环境安装
>服务器更改root密码 sudo passwd root >服务器ubuntu安装ssh apt-get install openssh-server >服务器开启root用户密码 ...
- 与你相遇好幸运,My Toolkit of Nodejs
>测试:restler.mocha.assert.request.request-promise >安装:nrm >运维:pm2.node-gyp >开发:nodemon.in ...
- 与你相遇好幸运,使用redis设置定时任务
参考链接: Nodejs中使用Redis来完成定时任务 自己在 window 7下编码实现: 1 > 首先查看redis版本: redis-server -v , 版本要求大于等于2.8 2&g ...
- 与你相遇好幸运,制作自己的Yeoman Generator
使用别人写好的生成器: npm install -g yonpm install -g generator-angularyo angular 如何自己制作符合自己心仪的生成器呢: https://g ...
- 与你相遇好幸运,gen8安装
gen8到手后,立马去买了 SSD https://item.jd.com/2010277.html 支架 https://item.jd.com/2671609.html NAS盘 https:// ...
- 与你相遇好幸运,德淘gen8历程
应该是十月底了 , 在浏览色魔张大妈(smzdm) http://www.smzdm.com/p/6517684/ 的时候看见了这个 , 以前大学就想买个这个 , 苦于没钱.... 然后当时打算买 , ...
- 与你相遇好幸运,用sinopia搭建npm私服
需求: >在企业内部搭建私有npm服务器,企业开发人员上传下载自己开发的npm包 >私有npm服务器包不存在时,找npm或者taobao的镜像站点 >服务器硬盘有限,希望只缓存下载过 ...
- 与你相遇好幸运,Postman设置Header不生效问题解决
POstMan安装地址 安装完 , Postman 设置Header的Referer不生效 , 提示 Restricted Header (use postman interceptor) 时 , 要 ...
随机推荐
- 重新注册IIS
出现问题的原因是先装了.NET4.0,再装IIS造成 处理方法:管理员权限执行cmd, C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_reg ...
- 运维自动化轻量级工具pssh
1pssh介绍 pssh是python写的可以并发在多台机器上批量执行命令的工具,它的用法可以媲美ansible的一些简单用法,执行起来速度比ansible快它支持文件并行复制,远程命令执行,杀掉远程 ...
- outlook 2016 for windows 每次刷新发送接收邮件会弹出登陆界面
Q: outlook2016 for windows 每次刷新发送接收邮件会弹出登陆界面,office365 ProPlus 都是正常激活了,Word 和Excel都不存在此类问题 A: 排除用户的o ...
- Nginx简易配置文件(三)(文件缓存)
server { listen 80; listen 443 ssl; server_name user.17.net userapi.17.net; access_log logs/user/acc ...
- 用 Python、 RabbitMQ 和 Nameko 实现微服务
用 Python. RabbitMQ 和 Nameko 实现微服务 原创 07-17 17:57 首页 Linux中国 "微服务是一股新浪潮" - 现如今,将项目拆分成多个独立的. ...
- elasticsearch curl operation
Elastic Search API Index.简单的介绍了使用Elastic Search 如何建立索引. ElasticSearch-API-Index 索引创建API允许初始化一个索引.Ela ...
- Java的生日
你知道巴西的税务系统,亚马逊的Kindle阅读器以及韩国的第一大镁板制造厂有什么共同点吗?乍一看上去,这简直就是风马牛不相及,但是这些系统同世界上其它100亿个设备共享一个元素,那就是Java. 19 ...
- centos ab命令安装
yum install apr-util -ymkdir abcd abyum -y install yum-utils -yyumdownloader httpd yum localinstall ...
- UITabBarController 、TabBar背景颜色设置,UITabBarItem的文字样式(颜色和大小)UITabBarItem的位置调整
改变UITabBarController的颜色 UIView*mView=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,48)];//这是部分tabb ...
- C# 自定义Section
一.在App.config中自定义Section,这个使用了SectionGroup <?xml version="1.0" encoding="utf-8&quo ...