Code Smell 76 - Generic Assertions

Code Smell 76 - Generic Assertions

Maxi Contieri
·Jun 7, 2021·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

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.


  • False Negatives

  • Lack of Trust


  1. Check the right case

  2. Assert for a functional case.

  3. Don't test implementation.

Sample Code


square = Square(5)

assert square.area() != 0

# This will lead to false negatives since it is too vague
square = Square(5)

assert square.area() = 25

# Assertion should be precise


With Mutation Testing techniques we can find these errors on our tests.


  • Testing


We should use development techniques like TDD that request concrete business cases and make concrete assertions based on our domain.


More info


This smell was inspired by Mario Cervera and used with his permission.

Photo by Fleur on Unsplash

A program that produces incorrect results twice as fast is infinitely slower.

John Osterhout

This article is part of the CodeSmell Series.

Share this


Technical Opinions are my own. I don't have the revealed truth.

Software Design is a creative activity. These are hints and not rigid rules.

I write on BackEnd Business Systems and OOP Design. My advice/experience might not suit other systems.

You can write me at info(at)