I am having a simple django project that contains some applications.Everything works well.Now how do i check code coverage for my project.I have installed coverge-3.5 tool and just tried to know coverage by typing "coverage report" from terminal..It shows some result like
NAME -----> (some file in my project)
STMS -----> (some number)
MISS -----> (some number)
COVER -----> (some %)
In my case,it will display some result that shows only some of the file names from my project.It didnt shows coverage for all files from my project.How do i make it to show all my file name ????
please suggest any better working coverage tool if you know !
I just got it working like this:
coverage run --source=app1,app2 ./manage.py test --settings=path.to.test_settings app1,app2
I don't think that this is the intended way to do it since we don't use the ./manage.py test_coverage command at all, but I couldn't find any other way.
first make sure you are using the latest coverage version. than you can do:
assuming your django project lives under project_parent/project, from project_parent run:
coverage html --include=project/*.*
this will give you a coverage report of your project only (i.e. doesn't output 3rd party lib coverage)
I manage to solve this issue with django_coverage and django_nose
I added to INSTALLED_APPS 'django_coverage' and 'django_nose'
with this on settings.py
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
# Tell nose to measure coverage on the 'foo' and 'bar' apps
NOSE_ARGS = [
'--with-coverage',
'--cover-package=schedule',
]
to install it
pip install django_coverage
How do I use it?
Install as a Django app Place the entire:
django_coverage app in your third-party apps directory.
Update your settings.INSTALLED_APPS to include django_coverage.
Include test coverage specific settings in your own settings file.
See settings.py for more detail. Once you've completed all the steps,
you'll have a new custom command available to you via manage.py test_coverage.
It works just like manage.py test.
Use it as a test runner
You don't have to install django_coverage as an app if you don't want to. You can
simply use the test runner if you like.
Update settings.TEST_RUNNER = 'django_coverage.coverage_runner.CoverageRunner' Include test coverage
specific settings in your own settings file. See settings.py for more
detail. Run manage.py test like you normally do.