Introduction
When software doesn't work as expected, it can be hard to know what to do first. Two important activities help find and fix problems: testing and debugging. Understanding how they differ helps solve issues faster and better.
Imagine you are checking a car before a trip. Testing is like inspecting the car to find any problems, such as checking the tires and lights. Debugging is like fixing the flat tire you found during inspection before you start driving.
┌─────────────┐ ┌─────────────┐
│ Testing │──────▶│ Debugging │
│ (Find bugs) │ │ (Fix bugs) │
└─────────────┘ └─────────────┘
▲ │
│ ▼
Planned checks Problem found by
before release testing or usersdef add(a: int, b: int) -> int: return a + b def test_add(): assert add(2, 3) == 5 assert add(-1, 1) == 0 assert add(0, 0) == 0 # Run tests test_add() # Debug example: fix a bug # Suppose add was incorrectly implemented as return a - b # Debugging would find and fix this error