Книга: Practical Programming, Fourth Edition
Назад: Exercises
Дальше: Why Do You Need to Test?

Chapter 15
Testing and Debugging

How can you tell whether the programs you write work correctly? Following the function design recipe from , you include an example call or two in the docstring. The final step of the recipe is to call your function and ensure it returns the expected result. But are one or two calls enough? If not, how many do you need? How do you pick the arguments for those function calls? In this chapter, you’ll learn how to choose good test cases and how to test your code using Python’s unittest module.

Finally, what happens if your tests fail, revealing a bug? (See .) How can you tell where the problem is in your code? This chapter will also teach you how to find and fix bugs in your programs.

Назад: Exercises
Дальше: Why Do You Need to Test?