Pragmatic Unit Testing:Summery

General Principles<o:p></o:p>

l       Test anything that might break<o:p></o:p>

l       Test everything that does break<o:p></o:p>

l       New code is guilty until proven innocent<o:p></o:p>

l       Write at least as much test code as production code<o:p></o:p>

l       Run local tests with each compile<o:p></o:p>

l       Run all tests before check-in to repository<o:p></o:p>

Questions to Ask<o:p></o:p>

l       If the code ran correctly, how would I know?<o:p></o:p>

l       How am I going to test this?<o:p></o:p>

l       What else can go wrong?<o:p></o:p>

l       Could this same kind of problem happen anywhere else?<o:p></o:p>

<o:p> </o:p>

What to Test: Use Your RIGHT-BICEP<o:p></o:p>

l       Are the results right?<o:p></o:p>

l       Are all the Boundary conditions CORRECT?<o:p></o:p>

l       Can you check Inverse relationships?<o:p></o:p>

l       Can you Cross-check results using other means?<o:p></o:p>

l       Can you force Error conditions to happen?<o:p></o:p>

l       Are Performance characteristics within bounds?<o:p></o:p>

Good tests are A TRIP<o:p></o:p>

l       Automatic<o:p></o:p>

l       Thorough<o:p></o:p>

l       Repeatable<o:p></o:p>

l       Independent<o:p></o:p>

l       Professional<o:p></o:p>

CORRECT Boundary Conditions<o:p></o:p>

l       Conformance . Does the value conform to an expected format?<o:p></o:p>

l       Ordering .    Is the set of values ordered or unordered as   appropriate?<o:p></o:p>

l       Range .       Is the value within reasonable minimum and maximum values?<o:p></o:p>

l       Reference .    Does the code reference anything external that isn't under direct control of the code itself?<o:p></o:p>

l       Existence .    Does the value exist? (e.g., is non-null, non-zero, present in a set, etc.)<o:p></o:p>

l       Cardinality .  Are there exactly enough values?<o:p></o:p>

l       Time (absolute and relative) . Is everything happening in order? At the right time? In time?<o:p></o:p>

你可能感兴趣的:(C++,c,C#,Go)