Testing for Correctness

Part of: Creative Development

What Testing Means Testing compares a program's actual output to its expected output . When they match, the test passes; when they differ, the test fails and points to a problem. Testing is how a team gains confidence that a program meets its requirements. Choosing Good Test Cases One test is never enough. Good testers cover several kinds of input: - Typical cases : ordinary, expected values. - Boundary cases : the smallest or largest allowed value, or the edge of a range. - Empty or unusual cases : no input, zero, or surprising values. Choosing inputs whose correct answer you already know lets you check the program objectively. A Testable Program Suppose a requirement says: given a number, print PASS if it is at least 60, otherwise FAIL. The boundary value 60 is the most important test, because off-by-one logic errors often hide there. Good test cases would include 60 (boundary), 100 (typical pass), and 0 (typical fail). Testing exactly at the boundary catches whether = should have been . Testing Drives Iteration When a test fails, the team returns to an earlier phase, makes a change, and tests again. This loop continues until all tests pass. Testing is therefore not a final step

Challenge: Pass or Fail