http://www.tuicool.com/articles/rAnaYvn

http://www.tuicool.com/articles/Y73aYn

(contrast stub and mock in java )http://www.cnblogs.com/TankXiao/archive/2012/03/06/2366073.html

http://shaynegui.com/javascript-unit-test-sinonjs/

http://shaynegui.com/javascript-unit-test-sinonjs/

http://sinonjs.org/docs/#spies

模拟输入可以用Sinon,它可以模拟包括ajax调用的各类程序调用来进行测试。也就是用Faker.js来生成软件测试时所需要的各式各样的数据。

test data generator: Faker.js

npm install -g faker-cli

Nodejs的单元测试工具

  1. 测试框架 mocha

  2. 断言库:should.js、expect.js、chai

  3. 覆盖率:istanbul、jscover、blanket

  4. Mock库:muk

  5. 测试私有方法:rewire

  6. Web测试:supertest

  7. 持续集成:Travis-cli

QUnit is very easy to get started with, as you only need to include two files(qunit.css and qunit.js) and a little bit of markup, then you can start writing tests. QUnit is TDD style tests.

Jasmine is easier to get started – it’s all-in-one package will generally get you and a team up and testing much faster, and you’ll be in good hands with it. Jasmine is BDD style tests.

Mocha is significantly more flexible, but you have to piece it together yourself. There is no spy framework built in to Mocha, so most people use sinon.js. There’s no assertion framework built in to Mocha either, so you’ll have to pick one. Chai is the popular one, but there are many, many others available. You can also configure Mocha for BDD (jasmine style) or TDD (QUnit style) easily. But you have to pick and choose how you want Mocha to work. This flexibility is great because you can build the test environment that you really want. But it means you have more work to do, more individual pieces to maintain /  keep up to date, etc.

nodejs unit test related----faker-cli, sinonjs, mock/stub的更多相关文章

  1. angular4.0 安装最新版本的nodejs、npm、@angular/cli的方法

    在使用ng项目的ui框架时,比如ng-zorro.angular Material,需要安装最新版本的@angular/cli: 配置ng-zorro框架 ng-zorro官网:https://ng. ...

  2. Method of offloading iSCSI TCP/IP processing from a host processing unit, and related iSCSI TCP/IP offload engine

    A method of offloading, from a host data processing unit (205), iSCSI TCP/IP processing of data stre ...

  3. 置换测试: Mock, Stub 和其他

    简介 在理想情况下,你所做的所有测试都是能应对你实际代码的高级测试.例如,UI 测试将模拟实际的用户输入(Klaas 在他的文章中有讨论)等等.实但际上,这并非永远都是个好主意.为每个测试用例都访问一 ...

  4. iOS測试——置换測试: Mock, Stub 和其它

    文章地址:http://ryantang.me/blog/2014/08/21/test-doubles/

  5. Unit Testing with NSubstitute

    These are the contents of my training session about unit testing, and also have some introductions a ...

  6. nodeJs 5.0.0 安装配置与nodeJs入门例子学习

    新手学习笔记,高手请自动略过 安装可以先看这篇:http://blog.csdn.net/bushizhuanjia/article/details/7915017 1.首先到官网去下载exe,或者m ...

  7. What's the difference between a stub and mock?

    I believe the biggest distinction is that a stub you have already written with predetermined behavio ...

  8. window下Nodejs的部署

    nodejs http://nodejs.org/#download npm node cli.js install npm -gf //可以安装最新版的NPM node cli.js install ...

  9. vue mock自己总结

    cli安装mock模块 npm   install  mockjs 创建mock文件夹 配置及创建文件 当后端写好真实接口以后,我们只需删掉创建的mock.js文件和在main.js中导入假数据的那行 ...

随机推荐

  1. mysql主从复制之mysql-proxy实现读写分离

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://lansgg.blog.51cto.com/5675165/1242674 本文系 ...

  2. log4cxx在linux下的编译使用

    最近在linux下使用log4cxx库,按照其官方文档提供的方法来进行编译,不能成功,又利用google搜索了好几个中文博客上讲述在linux下编译使用log4cxx库的方法,依然不能成功,在这里我奉 ...

  3. Oracle Restart能够用来给Oracle GoldenGate 做 High Availability 使用么?

    Oracle Restart能够用来给Oracle GoldenGate  做 High Availability 使用么? 来源于: Can Oracle Restart be used with ...

  4. POJ 2409 Let it Bead(Polya简单应用)

    Let it Bead 大意:给你m种颜色,n个珠子串起来.旋转跟反转同样算同样,问有多少种不同的涂色组合方式. 思路:Polya的简单应用. /*************************** ...

  5. hdoj 1288 Hat's Tea

    Hat's Tea Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total S ...

  6. mybatis3 sqlsession

    1.mybatis3中的通过openSession()方法打开的sqlsession,它的事务默认是关闭的,所以进行数据库完成操作之后,要记得commit(),也可以添加openSession(boo ...

  7. Intellij IDEA常用快捷键整理

    ps:使用Intellij IDEA编辑器有蛮长一段时间了.哈哈.整合一下常用的快捷.避免自己以后还要再找. 顺序大概就是从上到下的 Alt + ENTER : 自动修正,提示Alt + Insert ...

  8. position: absolute、relative的问题

    设置此属性值为 absolute 会将对象拖离出正常的文档流绝对定位而不考虑它周围内容的布局.假如其他具有不同 z-index 属性的对象已经占据了给定的位置,他们之间不会相互影响,而会在同一位置层叠 ...

  9. Cocos3.0 的android返回键功能实现

    比如:Game.h   Game.cpp 头文件Game.h中定义: void onKeyReleased(EventKeyboard::KeyCode keyCode,Event * pEvent) ...

  10. 编写Nginx启停服务脚本

    在/etc/init.d/目录下创建脚本 vim /etc/init.d/nginx 编写脚本内容:(其中下面2行需要根据情况自行修改) nginxd=/opt/nginx/sbin/nginx ng ...