← Back to context

Comment by brushfoot

11 days ago

> the time they spent on mocks easily outstripped the time a good build engineer would have spent creating a fast reusable test framework

This goes back to team size and skills. Not all teams have build engineers. And not all mocks are so complicated that they take up that much time.

Again, it depends on the scope and the resources. The article goes too far by calling mocking an anti-pattern. It simply isn't.

If I didn't have the team to properly do a good test build I would tell all my engineers to design their code to not need mocks if at all possible and call it a day at 85% coverage. That's very doable with dependency injection and modular function libraries. The time spent not chasing full coverage could be better spent improving CI/integration testing/deployment.

  • It depends. The type of project affects the decision too.

    If it's a small, standalone CRUD app on a SQLite database, mocks would probably be a bad option, sure.

    On the other hand, it could be an integration platform that integrates with many third-party services. Some of them may not have test environments. Or some of the integrations may be written by third-party contractors, and we can't expose service credentials because of poor permissions granularity. Mocks are a good option there.