Chapter 2. Running Automated Test Suites with Nose

In this chapter, we will cover:

  • Getting nosy with testing
  • Embedding nose inside Python
  • Writing a nose extension to pick tests based on regular expressions
  • Writing a nose extension to generate a CSV report
  • Writing a project-level script that lets you run different test suites

Introduction

In the previous chapter, we looked at several ways to utilize unittest in creating automated tests. Now, we will look at different ways to gather the tests together and run them. Nose is a useful utility built to discover tests and run them. It is flexible, can be run from either command-line or embedded inside scripts, and is extensible through plugin. Due to its embeddable nature, higher level tools, such as project scripts, it can be built with testing as an option.

What does nose offer that unittest does not? Key things include automatic test discovery and a useful plugin API. There are many nose plugins that provide everything from specially formatted test reports to integration with other tools. We will explore this in more detail in this chapter and in the latter parts of this book.

Note

For more information about nose refer to http://somethingaboutorange.com/mrl/projects/nose.

We need to activate our virtual environment and then install nose for these various recipes.

Create a virtual environment, activate it, and verify that the tools are working:

Introduction

Next, using pip, install nose, as shown in the following screenshot:

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

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