← Back to context

Comment by mehagar

12 days ago

I agree that if you need to write mocks, it's likely that your interfaces are poorly defined. This is one of the claimed benefits of test driven development - writing the tests first forces you to design the code in a way that cleanly separates modules so they can be tested.

You have to mock/fake when modules call dependencies.

Your way means you only ever have siblings. With an orchestrator pulling results out of one module and pushing it into another.

  • Code that uses hexagonal architecture/dependency inversion requires less mocks in their tests.

    • That’s… not true? No matter how you define your dependencies to inject, if you want to mock the dependencies you inject you have to mock them (it’s almost tautological), no matter if you use dependency inversion or not

      Maybe you mean "less surface to mock", which is irrelevant if you generate your mocks automatically from the interface

      3 replies →