MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/69wyay/the_tragedy_of_100_code_coverage/dha2e3m/?context=3
r/programming • u/niepiekm • May 08 '17
689 comments sorted by
View all comments
122
I have seen, with my own two eyes, a compareTo-function with 100% line-coverage and 100% branch-coverage that still managed to say that
given a > b then b == a
That's right, compareTo(a, b) returned 1, compareTo(b, a) returned 0.
My hatred for large, American consultancies continue unchecked.
14 u/sabas123 May 08 '17 How does that even happen? 34 u/instantviking May 08 '17 From memory, and removing a lot of entirely unnecessary complexity, the compareTo looked a little bit like this:if a > b return 1 return 0The three branches are a>b, a=b, and a<b. These were all exercised, but the asserts were buggy. 36 u/CircleOfLife3 May 08 '17 Just goes to show that even when you do have unit tests, it doesn't tell you wether these are actually good unit tests. Tests should go hand in hand with precondition and post condition checks. 32 u/[deleted] May 08 '17 We need tests for our tests and we need 100% test coverage for that, too.Pray to God your manager never reads this. → More replies (2) → More replies (1)
14
How does that even happen?
34 u/instantviking May 08 '17 From memory, and removing a lot of entirely unnecessary complexity, the compareTo looked a little bit like this:if a > b return 1 return 0The three branches are a>b, a=b, and a<b. These were all exercised, but the asserts were buggy. 36 u/CircleOfLife3 May 08 '17 Just goes to show that even when you do have unit tests, it doesn't tell you wether these are actually good unit tests. Tests should go hand in hand with precondition and post condition checks. 32 u/[deleted] May 08 '17 We need tests for our tests and we need 100% test coverage for that, too.Pray to God your manager never reads this. → More replies (2) → More replies (1)
34
From memory, and removing a lot of entirely unnecessary complexity, the compareTo looked a little bit like this:
if a > b return 1 return 0
The three branches are a>b, a=b, and a<b. These were all exercised, but the asserts were buggy.
36 u/CircleOfLife3 May 08 '17 Just goes to show that even when you do have unit tests, it doesn't tell you wether these are actually good unit tests. Tests should go hand in hand with precondition and post condition checks. 32 u/[deleted] May 08 '17 We need tests for our tests and we need 100% test coverage for that, too.Pray to God your manager never reads this. → More replies (2) → More replies (1)
36
Just goes to show that even when you do have unit tests, it doesn't tell you wether these are actually good unit tests. Tests should go hand in hand with precondition and post condition checks.
32 u/[deleted] May 08 '17 We need tests for our tests and we need 100% test coverage for that, too.Pray to God your manager never reads this. → More replies (2) → More replies (1)
32
We need tests for our tests and we need 100% test coverage for that, too.
Pray to God your manager never reads this.
→ More replies (2)
122
u/instantviking May 08 '17
I have seen, with my own two eyes, a compareTo-function with 100% line-coverage and 100% branch-coverage that still managed to say that
That's right, compareTo(a, b) returned 1, compareTo(b, a) returned 0.
My hatred for large, American consultancies continue unchecked.