-
Notifications
You must be signed in to change notification settings - Fork 0
Testing and Debugging
Python testing and debugging are optional practice for the Module Four Assignment. The graded deliverable is the pseudocode.
If you complete the optional Python program, testing helps you check whether the program actually follows your design.
The higher/lower game contains:
- Input validation
- Decision branches
- Loops
- A random number
A single successful game cannot show that every path works.
Use several runs and deliberately choose inputs that exercise different behaviors.
The Higher/Lower Game Sample Output provides useful behavior examples, including:
- A normal guessing sequence
- Invalid bounds followed by corrected bounds
- A guess outside the selected range
- Too-low and too-high feedback
- A correct guess
Your exact random value may differ during manual testing, so focus on whether the program responds correctly to the values that occur in your run.
The repository SRS separates the behavior into scenarios. Use those scenarios as a checklist so you do not test only the easiest path.
From the repository root:
python3 tests/test_hilow_game.pyThe optional tests control the random number so several behaviors can be repeated consistently. They assume the optional starter's provided randint import remains in place.
The automated checks are intentionally limited. Passing them does not prove that every assignment requirement is correct.
When a test fails, compare three things:
- Requirement — what should happen?
- Pseudocode — what did you design?
- Python — what did you implement?
Find the first place where they disagree. Fix one problem, then test again.
If the design is wrong, update the pseudocode first. If the design is correct but the program differs, update the program.
If a loop does not end when expected, inspect:
- The loop condition
- The values used by the condition
- What changes during each repetition
- Whether valid input or a correct guess can make the condition become false
Stop a runaway program from the VS Code terminal with Ctrl+C, then inspect the logic before running it again.