@zhongjianxin
2017-08-08T11:58:10.000000Z
字数 930
阅读 979
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!)
注意:单元测试不能针对方法编写测试,而应根据业务编写测试用例。一个测试方法只能做一件事情,代表一个测试样本和一个业务规则。
https://martinfowler.com/bliki/GivenWhenThen.html