博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nodejs unit test related----faker-cli, sinonjs, mock/stub
阅读量:4332 次
发布时间:2019-06-07

本文共 1643 字,大约阅读时间需要 5 分钟。

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.

 

转载于:https://www.cnblogs.com/SZLLQ2000/p/5387028.html

你可能感兴趣的文章
微软自己的官网介绍 SSL 参数相关
查看>>
Composite UI Application Block (CAB) 概念和术语
查看>>
ajax跨域,携带cookie
查看>>
阶段3 2.Spring_01.Spring框架简介_03.spring概述
查看>>
阶段3 2.Spring_02.程序间耦合_1 编写jdbc的工程代码用于分析程序的耦合
查看>>
阶段3 2.Spring_01.Spring框架简介_04.spring发展历程
查看>>
阶段3 2.Spring_02.程序间耦合_3 程序的耦合和解耦的思路分析1
查看>>
阶段3 2.Spring_02.程序间耦合_5 编写工厂类和配置文件
查看>>
阶段3 2.Spring_01.Spring框架简介_05.spring的优势
查看>>
阶段3 2.Spring_02.程序间耦合_7 分析工厂模式中的问题并改造
查看>>
阶段3 2.Spring_02.程序间耦合_4 曾经代码中的问题分析
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_2 spring中的Ioc前期准备
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_4 ApplicationContext的三个实现类
查看>>
阶段3 2.Spring_02.程序间耦合_8 工厂模式解耦的升级版
查看>>
阶段3 2.Spring_03.Spring的 IOC 和 DI_6 spring中bean的细节之三种创建Bean对象的方式
查看>>
阶段3 2.Spring_04.Spring的常用注解_3 用于创建的Component注解
查看>>
阶段3 2.Spring_04.Spring的常用注解_2 常用IOC注解按照作用分类
查看>>
阶段3 2.Spring_09.JdbcTemplate的基本使用_5 JdbcTemplate在spring的ioc中使用
查看>>
阶段3 3.SpringMVC·_07.SSM整合案例_02.ssm整合之搭建环境
查看>>
小D课堂 - 零基础入门SpringBoot2.X到实战_第1节零基础快速入门SpringBoot2.0_3、快速创建SpringBoot应用之手工创建web应用...
查看>>