Code Smell 76 — Generic Assertions
Don’t make weak tests to create a false sensation of coverage.
Don’t make weak tests to create a false sensation of coverage.
TL;DR: Test Assertions should be precise. Not too Vague and not too specific. There is no silver bullet.
Problems
False Negatives
Lack of Trust
Solutions
1. Check the right case
2. Assert for a functional case.
3. Don’t test implementation.
Sample Code
Wrong
Right
Detection
With Mutation Testing techniques we can find these errors on our tests.
Tags
Testing
Conclusion
We should use development techniques like TDD that request concrete business cases and make concrete assertions based on our domain.
Relations
Code Smell 30 — Mocking Business
Mocking is a great aid when testing behavior. Like with many other tools, we are abusing them.blog.devgenius.io
Code Smell 52 — Fragile Tests
Tests are our safety nets. If we don’t trust on their integrity we will be in great danger.blog.devgenius.io
More info
How to Squeeze Test Driven Development on Legacy Systems
We all love T.D.D. We know its benefits, we have read a thousand tutorials on how to build a system using this…blog.devgenius.io
The one and only software design principle
If we build our entire paradigm on a single rule, we can keep it simple and make excellent models.codeburst.io
Mutation testing - Wikipedia
Mutation testing (or mutation analysis or program mutation) is used to design new software tests and evaluate the…en.wikipedia.org
Credits
This smell was inspired by Mario Cervera and used with his permission.
A program that produces incorrect results twice as fast is infinitely slower.
John Osterhout
Software Engineering Great Quotes
Sometimes a short thought can bring amazing ideas.blog.devgenius.io
This article is part of the CodeSmell Series.
How to Find the Stinky parts of your Code
The code smells bad. Let’s see how toe the aromas.blog.devgenius.io


