-
Notifications
You must be signed in to change notification settings - Fork 0
Testing and Debugging
Testing ideas are useful in Module Four even though Python construction and testing are optional.
You can first trace the pseudocode by hand, then use manual and automated tests if you complete the optional Python practice.
Before writing Python, choose a required behavior and trace your pseudocode.
Useful cases include:
- invalid bounds followed by valid bounds;
- an out-of-range guess followed by a valid guess;
- a too-low valid guess;
- a too-high valid guess; and
- a correct guess that ends the game.
Follow each statement, branch, and loop literally.
If the design does not describe what should happen, correct the pseudocode before coding.
If you complete src/hilow_game.py, run it from the repository root:
python3 src/hilow_game.pyUse several runs because the target number is random.
Compare the program with:
- the official Guidelines and Rubric;
- the Higher/Lower Game Sample Output;
- the SRS; and
- your pseudocode.
The repository includes tests/test_hilow_game.py.
Run:
python3 tests/test_hilow_game.pyThe test code uses controlled input and a controlled target number to make selected paths repeatable.
You are not expected to understand or modify all of the testing code yet.
The tests are optional practice and are not part of the graded Module Four submission.
A passing optional test means the Python implementation satisfied the specific behavior checked by that test.
It does not mean:
- the pseudocode automatically earns full rubric credit;
- every possible behavior was tested; or
- the assignment was submitted.
Do not immediately change random code until the test turns green.
Instead compare, in order:
- Requirement: What should happen?
- Pseudocode: What did you design?
- Python: What did you implement?
- Observed behavior: What actually happened?
Find the first disagreement.
A useful cycle is:
Test → Find the first mismatch → Correct → Retest
If the pseudocode is wrong, revise the graded design first. Then update the optional code to match it.
If the code is wrong but the pseudocode is correct, keep the design and correct the implementation.
When repeated behavior is wrong, check:
- Is the loop condition the one you intended?
- Can something inside the loop change the condition?
- Is new input obtained when the player needs another attempt?
- Does an incorrect guess continue the game?
- Does a correct guess allow the guessing loop to stop?
- Is validation occurring at the right point?
The provided tests are course-managed practice tools.
If a test exposes a mismatch, correct the design or optional program as appropriate. Editing the test merely to remove the failure defeats the purpose of testing.
These are different tools:
- Assignment Checks verify repository integrity and basic completion state of the graded pseudocode.
- Optional Python tests exercise selected behaviors in the optional program.
A student does not need to complete the optional Python program to receive a green Assignment Check.
Return to Home or continue to Git and GitHub During the Assignment.