Skip to content
Preptima
mediumConceptScenarioEntryMidSenior

A test that has passed for a year starts failing after a refactor that was supposed to change nothing. Is it a bug or a bad test?

4 min readUpdated 2026-08-15

Answer

Short answer

Work out what the test was actually asserting.If it pins behaviour a user depends on, the refactor changed behaviour and the test did its job; if it pins an implementation detail, it never had value and the failure is the cost of having written it that way.

Was this answer helpful?

Likely follow-ups

  • The test asserts on the exact order of a returned list. Is that a contract?
  • What would you change so this test stops failing on refactors but still catches the regression?
  • How do you tell a genuinely flaky test from one that has just started catching a real race?
  • You cannot tell which it is and the release is today. What do you do?

Related questions