Book Image

Learning Flask Framework

Book Image

Learning Flask Framework

Overview of this book

Table of Contents (17 chapters)
Learning Flask Framework
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Unit testing


Unit Testing is a process that allows us to have confidence in the code, confidence in bug fixes, and confidence in future features. The idea of unit testing is simple; you write code that complements your functional code.

As an example, let's say we design a program that needs to calculate some math correctly; how do you know it's successful? Why not pull out a calculator, and you know what a computer is? A big calculator. Also, computers are really quite good at mundane repetitive tasks, so why not write a unit test that works out the answer for you? Repeat this pattern for all areas of your code, bundle those tests up into one wrapper, and you have complete confidence in the code that you have produced.

Note

There are some who say that tests are a sign of code "smell", that your code is so complex that it needs tests to prove that it works. This means that the code should be simpler. However, it really depends on your situation and it is up to you to make that judgment call...