← Back to context

Comment by nineplay

12 days ago

For some reason this article gives me flashbacks to the new CTO who comes in and declares 'micro-services' or 'containers' as the perfect solution for some problem that no one has actually run into. The article's author has had their pain points, but it doesn't mean all mocking is bad everywhere in every use case.

I wrote some code recently that detects cycle errors in objects with inheritance and I mocked the DB calls.

- Did I test for DB failures? No, but that's not the goal of the tests.

- Could I have refactored the code to not rely on DB calls? Yes, but every refactor risks the introduction of more bugs.

- Could I have launched a temporary DB instance and used that instead? Yes, but there's no obvious reason that would have been easier and cleaner than mocking DB calls.

In python it wasn't hard to implement. It was the first time I'd used the mock library so naturally there was learning overhead but that's unavoidable - any solution would have learning overhead.