DEV Community

Discussion on: Sometimes arbitrary rules have a place

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

You run the risk of either:

  • duplicated code coverage
  • invalid tests

If the author is writing a test for something that is already covered, then you end up with a duplicate test. This increases maintenance cost. It also risks confusing future contributos as they struggle to understand the difference between the tests. Probably not a tragic outcome though.

Invalid tests start to arise if people write tests for code unrelated to what they fixed or refactored. Now you have somebody writing a test which they lack complete knowledge and may end up writing an invalid one. Invalid tests hamper refactoring with false negatives -- testing conditions that weren't meant to be supported.

There's another aspect here though, the only way the code could be fully covered is if the PR is 100% refactoring, no bug fix nor new feature added. The moment it's a bug fix, or feature, implies there is a need for new test code. Though I find it unlikely that the code would be 100% covered anyway -- mainly since I don't believe 100% is something that can actually exist. :)