← Back to context

Comment by jweir

12 days ago

I tell my developers that each mock you use costs you $100. Maybe it is worth it, but probably not.

No I don't really charge em – but it gets the idea across that mocks have costs that you don't always see up front.

Maybe you’re writing them incorrectly then? I’ve written several that were for core app features used in 30ish test cases on a team with 7 engineers and they’ve worked flawlessly for over two years.

  • No, it is that mocks can hide interface changes. So if you have a mock, then you need to test that the interface works without the mock. And if you are doing that, why not just skip the mock?

    foo calls x(user, date) foo mock # tests pass

    x changes to x(user, time)

    but the tests for foo do not change, tests still pass, runtime errors.

    If you have static/strong typing the compiler will pick this up – but for dynamic languages you have a problem.