Chapter 7. Agile testing: where dynamic typing shines
This chapter covers
- The Python unittest module
- Creating a test framework
- Mock objects
- Testing techniques: monkey patching and dependency injection
- Functional testing
Testing is an increasingly important part of software development. Automated test suites allow you to easily include testing as part of your development process, rather than as a separate, time-consuming, and expensive manual process. The alternative is letting your customers find the bugs for you. Testing isn’t only about finding bugs early, though; writing code in a testable way encourages the writing of modular and loosely coupled code—which means better code. Additionally, when adding new features or refactoring, your tests can warn you about what other parts of your code you’ve broken. Fortunately, testing is an area where dynamic languages particularly shine.