All jobs / Backend developer / Testing

Backend developer interview question · 3–5 years

A refactor that changed no behaviour broke forty tests. Each one asserts that a particular method was called on a mock.

What is the lesson?

The strongest answer

The tests were pinned to the implementation rather than the behaviour — mock only what crosses a boundary you do not own, and assert on outcomes, so a refactor that keeps the contract keeps them green

Why it works

Exactly — a test that goes red on a safe refactor is a maintenance bill, not a safety net.

What a good answer covers

Answers that fall short

Who gets asked this

More Testing questions