What to Do When Unit Tests Pass but Production Hates You

by Arif Ikhsanudin, Backend Developer

Everything works on your machine, all unit tests green.
Then production screams, and suddenly you’re the villain.

Green Tests ≠ Safe Deployment

Unit tests are a safety net, not a crystal ball.

  • They only cover the cases they were written for
  • They don’t see production’s real-world data quirks
  • They can’t predict environment-specific behavior

Passing tests make you confident, not invincible.

Step Back and Observe

When production fails, the first instinct is panic—but slow down.

  • Check logs first: errors are rarely subtle
  • Compare production input/output with what your tests used
  • Look for hidden assumptions in the code

Your job is investigation, not blame.

Isolate the Problem

Production failures are rarely caused by a single line of code.

  • Identify which service or module is misbehaving
  • Verify configuration differences between staging and production
  • Confirm dependencies, versions, and network behavior

Breaking it down avoids a frantic all-hands debugging session.

Communication Is Key

Once you know the problem, keep your team informed.

  • Send clear updates to managers and stakeholders
  • Document what fails, why, and what’s being tested next
  • Avoid speculation or panic—clarity helps everyone act faster

Unit tests may have passed, but transparency wins the day.

Lessons for the Future

Use the incident to strengthen your safety net:

  • Add integration or system tests for production-like scenarios
  • Review environment parity between local, staging, and production
  • Remember: tests are tools, not proof of perfection

Production will always throw curveballs—anticipate them, don’t fear them.

Scale Your Backend - Need an Experienced Backend Developer?

We provide backend engineers who join your team as contractors to help build, improve, and scale your backend systems.

We focus on clean backend design, clear documentation, and systems that remain reliable as products grow. Our goal is to strengthen your team and deliver backend systems that are easy to operate and maintain.

We work from our own development environments and support teams across US, EU, and APAC timezones. Our workflow emphasizes documentation and asynchronous collaboration to keep development efficient and focused.

  • Production Backend Experience. Experience building and maintaining backend systems, APIs, and databases used in production.
  • Scalable Architecture. Design backend systems that stay reliable as your product and traffic grow.
  • Contractor Friendly. Flexible engagement for short projects, long-term support, or extra help during releases.
  • Focus on Backend Reliability. Improve API performance, database stability, and overall backend reliability.
  • Documentation-Driven Development. Development guided by clear documentation so teams stay aligned and work efficiently.
  • Domain-Driven Design. Design backend systems around real business processes and product needs.

Tell us about your project

Our offices

  • Copenhagen
    1 Carlsberg Gate
    1260, København, Denmark
  • Magelang
    12 Jalan Bligo
    56485, Magelang, Indonesia

More articles

Git Reflog: The Safety Net Most Developers Don't Know They Have

Reflog is a local log of every position HEAD has ever been in. It is the reason that almost nothing in Git is permanently irreversible — and most developers have never opened it.

Read more

Spring Boot API Documentation With OpenAPI — Generating, Hosting, and Keeping It Accurate

API documentation that drifts from the implementation is worse than no documentation — it misleads integrators and wastes time. Here is how to generate accurate OpenAPI specs from Spring Boot code, keep them in sync, and host them effectively.

Read more

What Mid-Level Developers Get Wrong About System Design

Mid-level developers often bring strong implementation skills into system design conversations and apply the wrong mental model. The gaps are predictable, and fixing them is less about knowledge than about shifting the frame.

Read more

Java Optional — What It's For, What It's Not For, and How to Use It Well

Optional is a return type that signals absence explicitly. It's not a null replacement, not a container to store in fields, and not a way to avoid NullPointerException everywhere. Used correctly, it improves API clarity. Used incorrectly, it adds allocation and verbosity without benefit.

Read more