Hacker News new | ask | show | jobs
by adamkl 2344 days ago
Yes! Yes! Yes! I've been preaching this approach ever since watching Gary Bernhardt's talk on "Boundaries" [1].

Splitting conditional logic from dependencies makes code so much easier to test. If you can do that, there's no need to mock anything. You can just pass simple data objects into your conditional logic for testing, and use a handful of integration tests to validate the end-to-end flow.

[1] https://www.destroyallsoftware.com/talks/boundaries

1 comments

Bertrand Meyer talked a similar strategy. I believe he called them decisions and actions. There's a lot of requirements tied up in decisions.

With the exception of callbacks (and async solves that for single-issue scenarios), arguments don't need to be mocked. They're just arguments.