ajib6ept
1/9/2019 - 5:23 PM

about coverage

# Install coverage using pip

pip install coverage

# Using coverage package

coverage run --source=app1,app2 ---omit=*/migrations/*  manage.py test

# Above command will executes the tests and stores the test results.

# To know the results run the below command

coverage report -m

# Above command will return results like below(example output).

Name                      Stmts   Miss  Cover   Missing
-------------------------------------------------------
app1/views.py                20      4    80%   33-35, 39
app1/models.py               20      4    80%   35-41, 57
app1/templatetags/ctags.py   56      6    89%   17-23
-------------------------------------------------------
TOTAL                        76     10    87%



#add Branch coverage

https://coverage.readthedocs.io/en/latest/branch.html

install the pytest-cov then Run pytest again and you’ll see the coverage report at the end of the Pytest report