[关闭]
@zhongjianxin 2017-08-08T11:58:10.000000Z 字数 930 阅读 979

Unit Test Skill

Trainning


测试基本原则

FIRST Principle
- 1.Fast: run (subset of) tests quickly (since you'll be running them all the time)
- 2.Independent: no tests depend on others, so can run any subset in any order
- 3.Repeatable: run N times, get same result (to help isolate bugs and enable automation)
- 4.Self-checking: test can automatically detect if passed (no human checking of output)
- 5.Timely: written about the same time as code under test (with TDD, written first!)

Test Double 类型


注意:单元测试不能针对方法编写测试,而应根据业务编写测试用例。一个测试方法只能做一件事情,代表一个测试样本和一个业务规则。

测试金字塔

image.png-119.4kB


image.png-128.5kB

Gievn-When-Then

https://martinfowler.com/bliki/GivenWhenThen.html

测试工具包

Junit Unit Testing
Junit List Test Examples

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注