use generator and co in mocha
来源:互联网 发布:茶叶网络连锁 编辑:程序博客网 时间:2024/05/30 23:10
主要的点在于当 it()
函数的回调函数带有done参数,mocha会等到回调函数里面出 done
或者或者超时才完成一条测试。同时因为每个测试用例最多执行2000毫秒,所以要面对需要很长时间的测试,需要通过设置 -t
来修改最长时间(暂时没有更好的方法)
it('option is empty', function(done) { ... done()//结束一条测试 });
例子
describe('runBash', function() { it('option is Sync', function(done) { var instructionList = ['echo "one"', 'echo "two"']; var option = { webRoot: '../fake-natoo' }; co(function*(done) { var errCode = yield runBash(instructionList, option); expect(errCode).to.be.equal(null); done();//完成测试 }.call(this, done));//传入done }); });
ps
Mocha默认每个测试用例最多执行2000毫秒(可以通过-t来调整)
Mocha默认会高亮显示超过75毫秒的测试用例(可以通过-s来调整)
<<测试框架 Mocha 实例教程>>(阮一峰)
0 0
- use generator and co in mocha
- hdl and c co-simulation in vcs
- Generator and Iterator in Python
- co与generator
- Co-使用co自动化执行Generator函数
- nodejs co generator 调用另外一个generator
- 新手如何玩co.generator
- Use external tools and builder in Eclipse
- use icc and ifort in openmpi
- VNC install and use in rhel6
- Install And Use Laravel Framework In Fedora25
- Use mybatis-generator
- install glm library in ubuntu and use it in qt
- install eigen in ubuntu and use it in qt
- How to use git in general and bitbucket in particular
- Define enum in xml and use it in another xml
- Testing in Node.js with Mocha
- High Performance Computing in Science and Engineering ' 05 : Transactions of the High Performance Co
- spring-aop注解配置
- Linux和windows环境下的Java开发的区别与不同
- dalvik机器码对照表
- BeautifulSoup 安装
- PAT甲级练习1053. Path of Equal Weight (30)
- use generator and co in mocha
- nfs部署和优化
- [BZOJ2540]ctsc2000快乐的蜜月(dp+归并排序)
- 【Codeforces 777 C Alyona and Spreadsheet】
- ListView源码分析(二)
- LeetCode : Ransom Note
- 元素为指针的vector的使用说明
- Java8系列之重新认识HashMap
- Node中require()的原理