Why Does the Company Keep Telling Me to Cut Down on Test Code?
I'm a junior developer. I've been trying hard to raise test coverage, but in code review I got told that forcing 100% coverage is excessive. They also say it hurts productivity.
I write tests out of habit because things broke a few times when I fixed code without them. I'm curious how senior developers decide what tests to write.
9 answers
Agreed, 100% test coverage is unrealistic.
I heard the same thing when I was a junior. These days I only write comments for the important logic, and it seems like there are actually fewer bugs.
Well, what company forces 100% coverage? Isn't the article exaggerated? In reality, it might have been a point about missing important tests.
Source?
The criterion is 'if this code breaks, does it cause an incident?' There's no need to write tests for presentation logic or simple getters. Instead, be sure to write tests for core domain logic.
If you have 100% coverage, ironically you can't refactor because of the test code lol
It varies by company, but coverage is usually just a metric. When they say to cut down on tests, it probably means cutting down on 'tests without value.' I was annoyed at first too, but it turned out my tests were too tied to implementation details. After listening to the advice and revising them, everyone was satisfied.
So it's based on line coverage, not branch coverage?
Tests are a maintenance cost too. It's true that blindly adding more hurts productivity, and seniors weigh the trade-offs. But asking to 'cut them down' is usually the wrong direction. Rather, the right move is to ask, 'Can you explain why this test is needed?'