Why Do You Need to Test?

Quality assurance, or QA, checks that software is working correctly. Over the last fifty years, programmers have learned that quality isn’t some kind of magic pixie dust that you can sprinkle on a program after it has been written. Quality has to be designed in, and software must be tested and retested to check that it meets standards.

The good news is that putting effort into QA actually makes you more productive overall. The later you find a bug, the more expensive it is to fix, so catching bugs early reduces overall effort. The reason can be seen in Boehm’s curve as shown.

images/modules/boehm.png

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 a dozen time zones away. This takes a little more time up front but makes programmers more productive overall, since every hour invested in preventing bugs saves two, three, or ten frustrating hours tracking bugs down.

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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.202.27