Now, we will use the pytest
command to run tests and measure their code coverage. Make sure you run the command in the Terminal or Command Prompt window in which you have activated the virtual environment, and that you are located within its root folder (Tornado01
). Run the following command:
pytest --cov -v
The test runner will execute all the functions defined in tests.py
that start with the test_
prefix, and will display the results. We use the -v
option to instruct pytest
to print the test function names and statuses in verbose mode. The --cov
option turns on test coverage report generation with the use of the pytest-cov
plugin.
The following lines show the sample output:
================================================ test session starts =================================================platform darwin -- Python 3.7.1, pytest-4.0.2, py-1.7.0, pluggy-0.8.0 -- /Users/gaston/HillarPythonREST2/Tornado01/bin/python3cachedir: .pytest_cache...