与你相遇好幸运,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) 时 , 要 ...
随机推荐
- time & datetime
时间相关的操作,时间有三种表示方式: 时间戳 1970年1月1日之后的秒,即:time.time() 格式化的字符串 2014-11-11 11:11, 即:t ...
- java spring mvc完整包下载地址
推荐使用该地址:http://maven.springframework.org/release/org/springframework/spring/ 更多详细参考地址:http://blog.cs ...
- 运行tomcat8w.exe未安装指定的服务
1.报错:指定的服务未安装. 2:解决方案有些写的不够详细,现在发表一遍详细操作手册 以上是解决方案备忘录
- .NET 学习书籍推荐
时间过得好快啊,转眼三月过了1周多了,今天把看书的目录记录下,方便初学者 最近由于项目需要研究下dotnet 技术,参考书籍如下: 1.深入理解C# 2.CLR via C# 3.Framework ...
- Servlet实现asp.net中的Global.asax启动事件(Servlet和Listener使用)
1.Java Web中没有像asp.net的全局启动事件,但是可以通过web.xml中的load-on-startup节点来控制Servlet的开机启动和启动次数.web.xml详细配置参考:http ...
- 我们为什么要学习Java
有人说Java已死,学Java还有前途吗? 这怎么可能呢? “Java已死”的论断从12年开始就反复有人提,但是直到今天,Java仍然活着,2015年还荣登TIOBE指数的编程语言奖,成为年度冠军.如 ...
- js获取url信息
设置或获取对象指定的文件名或路径. alert(window.location.pathname) 设置或获取整个 URL 为字符串. alert(window.location.href); 设置或 ...
- 浅谈Android中Activity的生命周期
引言 我想对于Android开发人员来说,Activity是再熟悉不过了,今天我们就来探讨下Activity的生命周期.熟悉的掌握Activity对于开发健壮的Android应用程序来说至关重要.下面 ...
- BootStrap 杂记
1:Bootstrap中的弹出窗口组件Modal 2:让div或者文字居中 在标签的class里加上 text-center .
- mysql配置远程连接方法之一(改表法)
1.问题:如果在远程连接报错:1130-host ... is not allowed to connect to this MySql server,可能是你的帐号不允许从远程登陆,只能在local ...