Find and Fix a Problem
- •
Use the vscode's build-in tool (execute/runTests) or the runTests tool to run the given unit tests and analyze the output carefully.
- •
Analyze the code carefully to find all possible causes of the problem.
- •
Think hard to create an extensive list of hypotheses of all possible causes of the problem.
- •
Important: Output all your hypotheses!
- •
Add extensive print statements to the code that help you confirm or disprove your hypotheses. For example:
Player tick positon += direction print "{this} moved in {direction} to {position}"
let cell = getCellAt position
print "{this} landed on cell type {cell?.type} at position {cell?.gridPos}"
6. Run the unit test again and carefully analyze the output of your print statements. The goal is to confirm one of your hypotheses. Repeat steps 1-6 until you can confirm one of your hypotheses.
- •
Once you confirmed a hypothesis, fix the problem.
- •
Repeat until the given unit test is passing.
- •
Remove all the print statements you added.