Chapter 3. Testing 1, 2, 3: Basic Unit Testing
In the previous chapter, we began learning about testing Django applications by writing some doctests for the Survey
model. In the process, we experienced some of the advantages and disadvantages of doctests. When discussing some of the disadvantages, unit tests were mentioned as an alternative test approach that avoids some doctest pitfalls. In this chapter, we will start to learn about unit tests in detail. Specifically, we will:
Re-implement the
Survey
doctests as unit testsAssess how the equivalent unit test version compares to the doctests in terms of ease of implementation and susceptibility to the doctest caveats discussed in the previous chapter
Begin learning some of the additional capabilities of unit tests as we extend the existing tests to cover additional functions