Hacker News new | ask | show | jobs
by GaryPalmer 1298 days ago
At the company I am working 80% of the code needs to be unit tested or you won't be able to commit. This results in tons of useless unit tests and you learn to restructure classes in a way that makes writing the unit tests later easy instead of what would make the most sense, for example exposings fields that should be private.
2 comments

I'm a huge proponent of good testing, mainly because it's so much easier to work sustainably on a code base with good tests. But I hate, hate, hate test coverage mandates. Every time I've seen them, it's as you say: some people write garbage tests to hit the metric. Before with those people you wouldn't have been able to trust their code. Now you have two problems, because you can't trust their tests either.
Sometimes you are forced to write a garbage test because there is not much to say about some simple code in terms of tests.
That's an interesting phrasing. Who forces you?
It's integrated into the build process. The build fails if there are not enough lines covered by tests.
You're lucky. It's 96% for me. I guesstimate that the tests are >2/3 of the development effort.