testem方便的web tdd 测试框架使用

备注:
   单元测试,对于日常的开发是比较重要的,testem 简化了我们的代码编写,以及运行。
   主要特性:
   a. 支持的测试框架有:jasmine quint mocha buster.js ,同时也包含一些其他的适配器,支持
   主流的浏览器。
   b. 可以方便的与持续集成工具进行集成(这个太方便了)。
   c.  跨平台
   d.  内置 coffeescript  browserify jshint /jslint 的支持
 
1. 安装
npm install -g testem  or  yarn global add testem (我比较喜欢的方式)
2. 使用
a. 启动
 testem 
备注:默认启动端口7357 的网站,可以试试查看测试信息
b. 一个简答的测试
touch Usertest.js

describe("firsttest",function(){
  it("consolelogtest",function(){
    console.log("ddd")
   }
  )
})

备注:写的测试比较简单,实际上内置了好多方便的断言库函数,可以直接使用
运行界面
 
 
3. 几个方便的命令
备注:主要是ci 模式
a. testem ci 
b. testem launchers (运行系统可以用的浏览器进行测试)
4. 配置文件( testem.json
格式如下:
{
  "framework": "jasmine",
  "src_files": [
    "hello.js",
    "hello_spec.js"
  ]
}

src_files 支持通配符如下:
{
  "src_files": [
    "js/**/*.js",
    "spec/**/*.js"
  ]
}
5. jenkins 、teamcity 集成插件(基于tap 协议)
jenkins:
https://wiki.jenkins.io/display/JENKINS/TAP+Plugin
teamcity:
https://github.com/pavelsher/teamcity-tap-parser
tap 协议:
http://testanything.org/
6. 扩展
包括配置测试模板、测试处理器、自定义配置测试浏览器参数,api proxy 可以参考官方说明,都是在开发中比较重要的。
7. 参考资料
https://github.com/testem/testem
https://wiki.jenkins.io/display/JENKINS/TAP+Plugin
https://github.com/pavelsher/teamcity-tap-parser
http://testanything.org/
https://github.com/testem/testem/blob/master/docs/config_file.md
 
 
 
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值