Book Image

Python Testing: Beginner's Guide

By :
Book Image

Python Testing: Beginner's Guide

By:

Overview of this book

<p>Automated testing moves much of the labor of testing off the developer and makes it easier as well as quicker to find bugs and fix them. Automated tests run faster, increase test coverage, and lower costs. However, testing is neither an easy process nor remotely exciting for most developers. But with the right techniques and tools, testing can become a simple and gratifying part of the development process.<br /><br />With this helpful guide – from an expert – in your hand, testing will not be a tiresome topic for you anymore. You will learn how to test your Python projects in the easiest way, making other parts of the development process easier and more enjoyable. <br /><br />This book covers the tools and techniques of automated testing and test-driven development. Starting from the very basics, the chapters introduce new tools and techniques in simple, accessible language with step-by-step examples. You will explore how to make testing easier and more accurate with Python's doctest module and learn test-driven development using the unittest framework. You will also learn how to keep your units separate from each other and discover a simple and easy way to integrate Mocker and unittest. Next, we cover integration testing and web application testing.<br /><br />Automated testing gives developers better feedback, faster and more often. Bugs get found sooner and fixed better, with less effort. By the end of this book, you will have all of the skills needed to benefit from automated testing.</p>
Table of Contents (17 chapters)
Python Testing
Credits
About the Author
About the Reviewers
Preface
Index

Chapter 9


Pop quiz – diagramming integration

  1. Those units wouldn't exist within the same class if they weren't related to each other. By grouping them into their classes visually, we can take advantage of that relationship to make our diagrams more easily.

  2. Usually, it saves us trouble later on. Things that are related to each other at one level are often part of the same thing at a higher level.

  3. In testing, as in chemistry, it's important to change only one thing at a time. If we pull together more than two things in a single step, we've changed more than one thing, and so we can lose track of where any problems we find came from.

Pop quiz – writing integration tests

  1. The ones in the smallest circles, especially if they don't have any lines pointing from themselves to other circles.

  2. Start from the smallest circles involving that code, and build up step by step until you're ready to integrate it with your earlier code.

  3. When we were doing unit testing, even other instances of the same class were mocked; we were concerned that this code did what it was supposed to, without involving anything else. Now that we're doing integration testing, we need to test that instances of the same class interact correctly with each other, or with themselves when they're allowed to retain state from one operation to the next. The two kinds of tests cover different things, so it makes sense that we would need both.

  4. A system test is the final stage of integration testing. It's a test that involves the whole code base.