DEV Community

Cover image for Code Smell 175 - Changes Without Coverage
Maxi Contieri ⭐⭐⭐
Maxi Contieri ⭐⭐⭐

Posted on • Originally published at maximilianocontieri.com

 

Code Smell 175 - Changes Without Coverage

If your merge request has no test changed, you haven't finished your job

TL;DR: Don't change the code without breaking some tests.

Problems

  • Quality

  • Maintainability

Solutions

  1. Cover your code.

Context

When you need to make a change, you need to update the live specification of your code.

That's why tests are for.

Instead of generating dead documentation of what your code does, you should write a covering use scenario.

If you change uncovered tests, you need to add coverage.

Suppose you change the code with existing coverage. Lucky you! Go and change your broken tests.

Sample Code

Wrong

export