I installed coverage.py to measure the code coverage for my Django project. (As mentioned here: https://docs.djangoproject.com/en/1.6/topics/testing/advanced/#integration-with-coverage-py)
But I currently have no test cases in my project. So, when I run coverage it says:
coverage run --source='.' manage.py test myapp
Creating test database for alias 'default'...
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
Destroying test database for alias 'default'...
It clearly says that it ran 0 tests, but when I say
coverage report -m
It gives me a report with code coverage of 91%. Also it looks into only the models package that I have. It does not look into other packages that are there as part of my app.
So when I give
coverage run --source='.' manage.py test myapp/mypackage
It once again reports coverage only for models package.
How do I measure the code coverage for all packages of the app? Kindly help. Thanks in advance.
myproject/
├── myapp
│ ├── models
│ ├── services
│ ├── statis
│ ├── templates
│ ├── utils
│ └── views
└── myproject
Report:
Name Stmts Miss Cover Missing
------------------------------------------------------------
manage 11 2 82% 8-9
myapp/__init__ 0 0 100%
myapp/admin 1 1 0% 1
myapp/models/__init__ 3 0 100%
myapp/models/form/__init__ 10 0 100%
myapp/models/form/items 57 0 100%
myapp/models/form/profile 14 0 100%
myapp/models/form/sections 10 0 100%
myapp/models/user/__init__ 21 0 100%
myapp/models/user/items 67 0 100%
myapp/models/user/profile 13 1 92% 9
myapp/models/user/sections 60 0 100%
myapp/tests 1 0 100%
myapp/urls 7 7 0% 1-9
myproject/__init__ 0 0 100%
myproject/manage 11 11 0% 2-16
myproject/settings 33 0 100%
myproject/urls 4 4 0% 1-6
myproject/wsgi 4 4 0% 10-14
------------------------------------------------------------
TOTAL 327 30 91%
When modules are missing from code coverage, a good first step is to check for any missing __init__.py
files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With