Книга: Practical Programming, Fourth Edition
Назад: Chapter 15: Testing and Debugging
Дальше: Case Study: Testing above_fr eezing

Why Do You Need to Test?

Quality assurance (QA) is the set of processes that ensure software is built to meet defined requirements and quality standards. Over the last half-century, programmers have learned that quality isn’t magic pixie dust you can sprinkle on a program after it’s written. Quality must be built in from the start, and software must be carefully designed, reviewed, and tested throughout its development.

The good news is that investing in QA makes you more productive overall. The later you find a bug, the more expensive it is to fix, so catching issues early reduces effort in the long run. The reason can be seen in Boehm’s curve:

Boehm diagram

This idea—that early testing pays off—is why modern software development places a strong emphasis on testing, particularly automated testing.

Finding and fixing bugs early reduces overall effort

Most good programmers today don’t just test their software while writing it; they build their tests so that other people can rerun them months later and across a dozen time zones. Building tests takes a little more time upfront but makes programmers more productive overall, since every hour invested in preventing bugs saves two, three, or ten frustrating hours tracking bugs down.

In , you learned how to run tests using Python’s doctest module. As part of the function design recipe (see ), you learned to include example calls on your function in the docstring. You can then use the module doctest to execute those function calls and have it compare the expected output with the actual output produced by that function call.

Назад: Chapter 15: Testing and Debugging
Дальше: Case Study: Testing above_fr eezing