Testing CS Thinking Example 3

Follow the full solution, then compare it with the other examples linked below.

Example 3

medium
A password validation function requires: at least 8 characters, at least one uppercase letter, and at least one digit. Design test cases that check each requirement independently.

Solution

  1. 1
    Step 1: Valid: 'Passw0rd' (meets all). Too short: 'Pa1' (fails length). No uppercase: 'password1' (fails uppercase). No digit: 'Password' (fails digit).
  2. 2
    Step 2: Boundary: 'Passwor1' (exactly 8 chars โ€” should pass). Each test isolates one requirement to identify exactly which check fails.

Answer

Test each requirement separately: valid, too short, no uppercase, no digit, exactly 8 characters.
Isolating test cases to check one requirement each makes it easy to locate bugs. If a test fails, you know exactly which validation rule has the problem.

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