krystal / katapult-cli

CLI tool to interact with Katapult API
MIT License
1 stars 1 forks source link

Potentially use gomock if tests start getting too complex #22

Open IAmJSD opened 3 years ago

IAmJSD commented 3 years ago

I believe this custom mock is starting to reach the point of complexity and custom logic where simply using gomock and explicitly mocking each function call and return values within each test case yields clearer and easer to understand tests.

I'm not gonna push for this to be changed to gomock right now, as it's already here and works well, but I think if we come back to it in the future and need to further expand it with more custom logic and state, a refactor to gomock would be a good idea.

_Originally posted by @jimeh in https://github.com/krystal/katapult-cli/pull/17#discussion_r675469153_

strideynet commented 3 years ago

I'm not sure I'm sold on this argument.

In my opinion, frameworks like Gomock can create extremely fragile tests, especially if the order of calls is asserted. Ultimately, I expect tests to test behaviour, not implementation detail. I find when using GoMock etc I spend a lot of time looking at the unit under test, rather than writing tests that consider the actual desired behaviour (outputs to inputs). I'd be interested in doing a side by side comparison of tests written both ways for a more complicated function before coming to a conclusion on this.