Code Smell 52 — Fragile Tests
Tests are our safety nets. If we don’t trust on their integrity we will be in great danger.
- Confidence loss
- Wasted time
- Test should be in full control. There should be no space for erratic behavior and degrees of freedom.
- Remove all tests coupling.
Coupling: The one and only software design problem
A root cause analysis of all failures of our software will find a single culprit with multiple costumes.
Fragile, Intermittent, Sporadic or Erratic tests are common in many organizations.
Nevertheless, they mine the developers trust.
We must avoid them.
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.
How to Avoid Fragile Unit Tests?
I've had this problem as well. My improved approach has been as follows: Don't write unit tests unless they're the only…
Fragile tests show system coupling and not deterministic or erratic behavior.
Developers spend lots of time and effort fighting against this false positives.
The amateur software engineer is always in search of magic.
This article is part of the CodeSmell Series.