Thursday, May 28, 2015

Re: Django Test Coverage

Hello,

IMHO it is much better to see the coverage values for everything (even tests.py). Your actual case, for example, shows that only 98 lines are running from your 100 lines long tests.py. This may mean that there is a condition somewhere in your test cases that never evaluates to true.

If you want to see the lines that are not covered, assuming you are using the "standard" coverage.py tool, you can use the command `coverage html` so it will generate a HTML version of the coverage info. In case you can't access such HTML files, you can use either `coverage report --show-missing` to see line numbers that are not covered, or `coverage annotate modulename` to create an annotated version of your module file that will show you different execution information in your source files.

Kind regards,
Gergely

2015-05-28 13:18 GMT+02:00 Dharmit Shah <shahdharmit@gmail.com>:
Hello all,

I have a django app which is full REST APIs created using Django Rest Framework.

In tests.py, I am testing fthe APIs using self.client.post and
self.clilent.get. I use coverage tool to figure out the test coverage
but it seems to check the coverage in a way I don't really understand.

When I check test coverage for just views.py file, it says 37% and
when I do that for tests.py, it says 98%.

Is there a way to determine test coverage only by looking at views.py
and checking how many of the views in it are tested in tests.py?

Or is it an unreasonable expectation?

Regards,
Dharmit.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJQZradk25770YeOGjHT4tBRaJsrexo578pt7xnHFRKZ0hAWFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACczBUJZ6r6KEWg8Q7DWWVeC79hYSi9J3L%2BfEUTk87N4APUwnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment