Skip to content

Testing and Debugging

mike-snhu edited this page Aug 16, 2026 · 2 revisions

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.

One Run Is Not Enough

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.

Start With the Official Sample Scenarios

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.

Use the SRS Acceptance Conditions

The repository SRS separates the behavior into scenarios. Use those scenarios as a checklist so you do not test only the easiest path.

Run the Provided Practice Tests

From the repository root:

python3 tests/test_hilow_game.py

The 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.

Debugging Is Comparison

When a test fails, compare three things:

  1. Requirement — what should happen?
  2. Pseudocode — what did you design?
  3. 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.

Watch for Infinite Loops

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.

Clone this wiki locally