Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
94dreamer committed May 31, 2017
1 parent bf3e446 commit 7979b35
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
Binary file modified .DS_Store
Binary file not shown.
Binary file added 前端的TDD开发探索/.DS_Store
Binary file not shown.
52 changes: 52 additions & 0 deletions 前端的TDD开发探索/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
### 前端的TDD开发探索

> 前言:`TDD` 测试驱动开发。
## 目录

* [What? 测试/TDD](#What? 测试/TDD)
* [Why? 测试/TDD](#Why? 测试/TDD)
* [单元测试](#单元测试)



## What? 测试/TDD

什么是测试?我们开发者描述的开发过程中测试,一般来说:
是编写一段检测你应用代码是否按预期执行的代码并执行的过程。

什么是TDD?是测试驱动开发的英文简写。一般来说:
是在编写生产代码之前,先用一段测试代码来描述应用的执行流程,然后再让生产代码按测试代码的意图来走通逻辑流程。

## Why? 测试/TDD

因为你可以通过编写测试来使你的应用更可靠,更容易重构。

## 单元测试

单元测试就是以代码模块为单元进行测试。给单元测试一个输入,让它自动执行,将输出结果和预期结果做对比看其是否正确(输入可以是一个函数参数,输出就是函数的返回值)。

### 使用测试框架

我们在编写测试代码时候,需要使用测试框架,目前比较流行的框架是Mocha,另外还有一些像 Jest/Jasmine/Tape 等框架也可以使用。

### 使用 Mocha 进行单元测试

我们一般需要在命令行运行我们的测试框架启动,为了节省时间,我们把启动代码保存到 npm script 中,也就是`package.json`

```
"scripts": {
...
"test": "mocha 'test/**/test-*.js' && eslint test lib",
...
},
```

上面的命令行 会 运行 test文件夹中所有以 `test-` ,把所有测试都放在测试目录是一个不错的做法。







2 changes: 1 addition & 1 deletion 触屏开发规范及优化思路/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


### 一 项目前端架构设想(自动化与规范化)
1. 放弃AMD/CDM模块化规范,主要使用ES6模块化来规范js/css引用,但按需加载部分依旧使用require,Webpack打包,并vendor基础库。
1. 放弃AMD/CMD模块化规范,主要使用ES6模块化来规范js/css引用,但按需加载部分依旧使用require,Webpack打包,并vendor基础库。
2. 基础库:FastClick/Flexible/JQuery(Zepto)/Template/Lazyload/Spin/
3. 考虑团队baiduTemplate/handlebars 选其一作为前端模板引擎
4. 引入ES6/Babel/Sass/PostCSS
Expand Down

0 comments on commit 7979b35

Please sign in to comment.