Reader small image

You're reading from  Learning Python Application Development

Product typeBook
Published inSep 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781785889196
Edition1st Edition
Languages
Right arrow
Author (1)
Ninad Sathaye
Ninad Sathaye
author image
Ninad Sathaye

Ninad Sathaye has spent several years of his professional career designing and developing performance-critical engineering applications written in a variety of languages, including Python and C++. He has worked as a software architect in the semiconductor industry, and more recently in the domain of Internet of Things. He holds a master's degree in mechanical engineering.
Read more about Ninad Sathaye

Right arrow

Unit testing


In unit testing, you tinker with a code fragment within the application. The main task is to verify that this piece of code continues to work as expected throughout the life of the application. This is accomplished by writing a test for that functionality.

A unit test can be better explained with an example. Consider a trivial function that returns the sum of two numbers. In a unit test, you invoke this function by passing two numbers as arguments, and then verify the value returned by the function is indeed the sum of the given numbers.

There are many frameworks available for writing unit tests. The examples in this chapter will be based on the built-in unit testing framework called unittest. See the heading Other unit testing tools, which gives a very short overview of alternative unit testing tools and frameworks.

Python unittest framework

The unittest module provides the functionality to automate tests. Before we implement any tests for our application, let's first start with...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Python Application Development
Published in: Sep 2016Publisher: PacktISBN-13: 9781785889196

Author (1)

author image
Ninad Sathaye

Ninad Sathaye has spent several years of his professional career designing and developing performance-critical engineering applications written in a variety of languages, including Python and C++. He has worked as a software architect in the semiconductor industry, and more recently in the domain of Internet of Things. He holds a master's degree in mechanical engineering.
Read more about Ninad Sathaye