Testing CS Thinking Example 2
Follow the full solution, then compare it with the other examples linked below.
Example 2
mediumA program grades students: 90-100 = A, 80-89 = B, 70-79 = C, 60-69 = D, below 60 = F. Design a complete set of test data including boundary values.
Solution
- 1 Step 1: Normal values: 95 (A), 85 (B), 75 (C), 65 (D), 50 (F). One from each grade band.
- 2 Step 2: Boundary values: 100, 90, 89, 80, 79, 70, 69, 60, 59, 0. These are at the edges where the grade changes.
- 3 Step 3: Erroneous values: -5, 101, 'abc'. These should be rejected or handled. Boundary testing is crucial because off-by-one errors are extremely common.
Answer
Normal: one per grade. Boundary: values at each grade boundary (90, 89, 80, 79...). Erroneous: negative, >100, non-numeric.
Systematic test design covers normal, boundary, and erroneous cases. Boundary values are where most bugs occur, especially off-by-one errors in conditional statements.
About Testing
Systematically running a program with known inputs to verify that its outputs are correct. Testing involves designing test cases that cover normal inputs, boundary values, and error conditions, then comparing actual results against expected results.
Learn more about Testing โMore Testing Examples
Example 1 easy
A function isEven(n) should return TRUE if n is even and FALSE otherwise. Suggest three test cases,
Example 3 mediumA password validation function requires: at least 8 characters, at least one uppercase letter, and a
Example 4 hardExplain the difference between white-box and black-box testing. Which approach would you use to test