Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3 Testing and Debugging

Where should you start building a system? With stories you want to be able to tell about the finished system.

Kent Beck

Poll time. What does your development process look like?

  1. I don’t test my code at all.

  2. I implement some code and then I test it.

  3. I create a test and then implement the code.

Software development is easier when feedback arrives early. Tests help you state what the code should do before or while you implement it, and debugging helps you inspect what the code is actually doing when reality does not match your expectations.

In this chapter, we focus on two practical skills. First, you will learn how to write automated functional tests in Python, starting with lightweight doctest examples and then moving to pytest, the Arrange-Act-Assert pattern, and the Visual Studio Code testing workflow. Then you will use the Visual Studio Code debugger to investigate a failing program by inspecting variables, stepping through execution, and working with breakpoints, logpoints, and exception handling.

Together, these practices support a tighter development loop: tests clarify behavior, and debugging helps you explain failures precisely enough to fix them.