Creating the first simple test
Testing is one of the strongest pillars of any software during development and, later, during maintenance and expansion. Especially in the case of web applications, where the application will handle high traffic and be scrutinized by a large number of end users at all times, testing becomes pretty important, as the user feedback determines the fate of the application. In this recipe, we will see how to start with test writing and also see more complex tests in the recipes to follow.
Getting ready
We will start with the creation of a new test file named app_tests.py
at the root application level – that is, alongside the my_app
folder.
How to do it…
Let’s write our first test case:
- To start with, the content of the
app_tests.py
test file will be as follows:import os
from my_app import create_app, db, babel
import unittest
import tempfile
The preceding code describes the imports needed for this test suite. We...