1
Pragmatic Unit Testing: Summary The following checklists are extracted from the book Pragmatic Unit Testing in Java with JUnit, part of the Pragmatic Starter Kit series. More information is available at http://www.pragmaticprogrammer.com/sk/ut, where you can also order PDF and paper copies of this book and our other titles. General Principles: Test anything that might break Test everything that does break New code is guilty until proven innocent Write at least as much test code as production code Run local tests with each compile Run all tests before check-in to repository Questions to Ask: If the code ran correctly, how would I know? How am I going to test this? What else can go wrong? Could this same kind of problem happen anywhere else? What to Test: Use Your Right-BICEP Are the results right? Are all the boundary conditions CORRECT? Can you check inverse relationships? Can you cross-check results using other means? Can you force error conditions to happen? Are performance characteristics within bounds? Good tests are A TRIP Automatic Thorough Repeatable Independent Professional CORRECT Boundary Conditions Conformance — Does the value conform to an expected format? Ordering — Is the set of values ordered or unordered as appropriate? Range — Is the value within reasonable minimum and maximum values? Reference — Does the code reference anything external that isn’t under direct control of the code itself? Existence — Does the value exist? (e.g., is non-null, non-zero, present in a set, etc.) Cardinality — Are there exactly enough values? Time (absolute and relative) — Is everything happening in order? At the right time? In time? Copyright c 2004 The Pragmatic Programmers, LLC. All Rights Reserved

Pragmatic Unit Testing - The Pragmatic Programmermedia.pragprog.com/titles/utj/StandaloneSummary.pdf · Pragmatic Unit Testing: Summary The following checklists are extracted from

Embed Size (px)

Citation preview

Page 1: Pragmatic Unit Testing - The Pragmatic Programmermedia.pragprog.com/titles/utj/StandaloneSummary.pdf · Pragmatic Unit Testing: Summary The following checklists are extracted from

Pragmatic Unit Testing: Summary

The following checklists are extracted from the book Pragmatic Unit Testing in Java

with JUnit, part of the Pragmatic Starter Kit series. More information is available athttp://www.pragmaticprogrammer.com/sk/ut, where you can also order PDF and papercopies of this book and our other titles.

General Principles:

2 Test anything that might break

2 Test everything that does break

2 New code is guilty until proven innocent

2 Write at least as much test code asproduction code

2 Run local tests with each compile

2 Run all tests before check-in to repository

Questions to Ask:

2 If the code ran correctly, howwould I know?

2 How am I going to test this?

2 What else can go wrong?

2 Could this same kind of problemhappen anywhere else?

What to Test: Use Your

Right-BICEP

2 Are the results right?

2 Are all the boundary conditionsCORRECT?

2 Can you check inverse relationships?

2 Can you cross-check results using othermeans?

2 Can you force error conditions tohappen?

2 Are performance characteristics withinbounds?

Good tests are A TRIP

2 Automatic

2 Thorough

2 Repeatable

2 Independent

2 Professional

CORRECT Boundary Conditions

2 Conformance — Does the value conform to an expected format?

2 Ordering — Is the set of values ordered or unordered as appropriate?

2 Range — Is the value within reasonable minimum and maximum values?

2 Reference — Does the code reference anything external that isn’t under direct controlof the code itself?

2 Existence — Does the value exist? (e.g., is non-null, non-zero, present in a set, etc.)

2 Cardinality — Are there exactly enough values?

2 Time (absolute and relative) — Is everything happening in order? At the right time?In time?

Copyright c© 2004 The Pragmatic Programmers, LLC. All Rights Reserved