Pragmatic Unit Testing:Summery
General Principles
l Test anything that might break
l Test everything that does break
l New code is guilty until proven innocent
l Write at least as much test code as production code
l Run local tests with each compile
l Run all tests before check-in to repository
Questions to Ask
l If the code ran correctly, how would I know?
l How am I going to test this?
l What else can go wrong?
l Could this same kind of problem happen anywhere else?
What to Test: Use Your RIGHT-BICEP
l Are the results right?
l Are all the Boundary conditions CORRECT?
l Can you check Inverse relationships?
l Can you Cross-check results using other means?
l Can you force Error conditions to happen?
l Are Performance characteristics within bounds?
Good tests are A TRIP
l Automatic
l Thorough
l Repeatable
l Independent
l Professional
CORRECT Boundary Conditions
l Conformance . Does the value conform to an expected format?
l Ordering . Is the set of values ordered or unordered as appropriate?
l Range . Is the value within reasonable minimum and maximum values?
l Reference . Does the code reference anything external that isn't under direct control of the code itself?
l Existence . Does the value exist? (e.g., is non-null, non-zero, present in a set, etc.)
l Cardinality . Are there exactly enough values?
l Time (absolute and relative) . Is everything happening in order? At the right time? In time?
发表评论
- 浏览: 53939 次
- 来自: 北京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
学习“五笔”输入法
二级简码助记词: 几多灾雪下帝城,四处冰霜亿地阴,三年六载不平事,五度思家小儿孙 ...
-- by rocflytosky -
学习“五笔”输入法
一级简码: 一地在要工,上是中国同,和的有人我,主产不为这,民了发以经。 ...
-- by rocflytosky -
推荐使用免费的WPS
纯文本编辑器和LaTeX就够用了
-- by arust -
推荐使用免费的WPS
gigix 写道OpenOffice.org OpenOffice跟Word兼 ...
-- by rocflytosky -
推荐使用免费的WPS
当年我在银行的一个哥们写了个WPS for UNIX,成为我们做报表templa ...
-- by ray_linn






评论排行榜