Chapter 5. Unit Testing and Refactoring
Here is a quick recap of what you have learned so far. You developed a command-line application using the OOP approach, and then learned techniques to make your code robust by handling exceptions. You modularized the code, prepared a distribution, and released it to a broader audience. Finally, you learned about coding standards and documentation.
So far, we have not paid much attention to testing the application. We relied solely on manual testing, where some features were tested by playing the game. The task of manual testing becomes increasingly difficult with the complexity of the application. Soon you will be overwhelmed, and the bugs will start to creep in. While manual testing may not be avoided completely, we need an automated way to make sure the features work as expected. In this chapter, you will do the following:
- Learn about unittest, the unit testing framework in Python
- Write some unit tests for our application
- See how to use the...