程序员应该在写代码前,完成快速的,独立的,可重复的,自己验证和时效性的测试Case。
F
快速:测试必须非常快,这样开发人员可以对每一个小更改运行测试,而不用中断思绪去等待测试运行。
I
隔离:不同的测试用例之间是隔离的。一个测试不会依赖另一个测试。不同测试的故障是相互隔离的。
R
可重复:测试是可重复的;可重复意味着可以自动化。在循环运行时,测试总能给出相同的结果。
S
自我验证:测试可以验证它们的结果,当它们全部通过时,给出一个简单的“OK”报告,当它们失败时,描述简明的细节。
T
及时:测试是及时的。程序员在代码上线前,及时地编写它们,以防止bug。
附英文原版
Fast
Tests are fast, so fast that developers run them with every small change without waits that break the flow.
Isolated
Tests are isolated. One test does not set up the next test. Tests also isolate failures.
Repeatable
Tests are repeatable; repeatable means automated. Tests run in a loop always giving the same result.
Self-verifying
Tests verify their outcome, reporting a simple “OK” when they pass while providing concise details when they fail.
Timely
Tests are timely. Programmers write them just in time, in lock-step (but just before) the production code, preventing bugs.
网友评论