Book build date (Is the date on page 1): 2020-07-29
Book format (PDF, Epub or Mobi): PDF
Chapter or Appendix: Test All the Cheese Views
Section: Start With Imports
What operating system are you using:
[ x ] Ubuntu Linux 18.08
Description
I noticed that after adding the test_good_cheese_list_view test, the code coverage decreases. In theory if you add more tests, either the % coverage should go up or stay at least the same (if it's a useless test) no?
Note 1st: from 17% goes to 15%.
Note 2nd: from 25% goes to 23%
etc.
After adding the test_good_cheese_detail_view the % coverage goes down even more... why?
Actually, after adding each test and running the coverage command, the % of all the other files except test_views.py (this one stays 100% all the time) goes down... why?
Possible Solutions
I'd like to hear a possible solution from the experts for this... also it would be nice to explain this in the book, becaus I'm sure many attentive readers will notice this behavior and wonder why.
I guess that by adding code, the amount of code goes up, but I thought there should be some smart way to make coverage understand to ignore tests, I mean code in tests in not code that need to be tested.
Note: all tests in test_views.py that have been added in this chapter are not inside a class, like the others in the same file, see class TestUserUpdateView and class TestUserRedirectView can this be the reason?
Your full name so we can provide accurate credit within the book
Location within the Book
Description
I noticed that after adding the
test_good_cheese_list_view
test, the code coverage decreases. In theory if you add more tests, either the % coverage should go up or stay at least the same (if it's a useless test) no?Check this out:
Note 1st: from 17% goes to 15%. Note 2nd: from 25% goes to 23% etc.
After adding the
test_good_cheese_detail_view
the % coverage goes down even more... why?Actually, after adding each test and running the coverage command, the % of all the other files except
test_views.py
(this one stays 100% all the time) goes down... why?Possible Solutions
I'd like to hear a possible solution from the experts for this... also it would be nice to explain this in the book, becaus I'm sure many attentive readers will notice this behavior and wonder why.
I guess that by adding code, the amount of code goes up, but I thought there should be some smart way to make coverage understand to ignore tests, I mean code in tests in not code that need to be tested.
Note: all tests in
test_views.py
that have been added in this chapter are not inside a class, like the others in the same file, see classTestUserUpdateView
and classTestUserRedirectView
can this be the reason?Your full name so we can provide accurate credit within the book
Paolo Brocco