Muhammed Senussi
Muhammed Senussi
  • Muhammed Senussi
Test What Actually BreaksJava

Coverage measures which lines ran, not which behaviours are protected. Those are different questions and only one of them matters at three in the morning.

Where the bugs actually live

In the incidents I have reviewed, almost none were a method returning the wrong arithmetic. They were boundaries: a serialisation change, a timezone, a nullable column that became non-nullable, a retry that was not idempotent.

  • Test the contract at the edge of your service, not the getters behind it.
  • Pin serialisation with a real payload from production, not a builder.
  • Give every retry an idempotency test, because that is where duplicate charges come from.

Delete the tests that only assert the mock was called. They cost maintenance and catch nothing.

2 Comments

  • Peter Bakker

    August 14, 2024

    Strong agree on serialisation. We now keep a folder of captured production payloads as fixtures and it has paid for itself twice.

    • Muhammed Senussi

      Muhammed Senussi

      AuthorAugust 14, 2024

      Same here, with one caution: scrub them properly. A fixtures folder is the easiest place in a repository to accidentally commit real customer data.

Leave a comment