Preferences

> Am I suggesting 100% test coverage? No, I’m not suggesting it. I’m demanding it. Every single line of code that you write should be tested. Period.

This is from uncle bob. I hate the argument by people that 100% leads to "bad quality tests". Not doing it leads to bad quality code, people who don't care about quality of code, and hence dont write tests, suddenly start to care about quality of tests.


On literally every project I've seen that enforces a % threshold, that % threshold has directly led to bad quality tests. This is more true the higher the % is, with the worst being 100%.

You can argue that it _shouldn't_ be this way, and I would agree, but it is that way. Perhaps in part because developers are humans, and even humans with the best initial intentions will game metrics with a large enough sample size over a long enough time horizon.

100% means testing things getters and setters in Java. At some point you're testing nothing.

If you tell people that 95% is just as inadequate as 0%, they'll tend towards 0%.

There are two possibilities

1. The getters and setters are not called anywhere in application logic. In that case, delete the getters / setters and get to 100%.

2. The getters and setters are called somewhere in the application logic. In that case, they should have already been covered in the test for the application.

There is really no excuse to not write tests to get to 100%.

> The getters and setters are not called anywhere in application logic

It's common that getters and setters will be called by serialization library. The fact that they are "grey" in IntelliJ doesn't matter.

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal