Code Smell 52 - Fragile Tests

Subscribe to my newsletter and never miss my upcoming articles

Tests are our safety nets. If we don't trust on their integrity we will be in great danger.

Problems

  • Determinism

  • Confidence loss

  • Wasted time

Solutions

  1. Test should be in full control. There should be no space for erratic behavior and degrees of freedom.

  2. Remove all tests coupling.

Examples

  • Fragile, Intermittent, Sporadic or Erratic tests are common in many organizations.

Nevertheless, they mine the developers trust.

We must avoid them.

Sample Code

Wrong

Detection

Detection can be done with test run statistics.

It is very hard to put some test in maintenance since we are removing a safety net.

More Info

Tags

  • Coupling

  • Determinism

Conclusion

Fragile tests show system coupling and not deterministic or erratic behavior.

Developers spend lots of time and effort fighting against this false positives.

Credits

Photo by Jilbert Ebrahimi on Unsplash


The amateur software engineer is always in search of magic.

Grady Booch


This article is part of the CodeSmell Series.

No Comments Yet