Kolos65 / Mockable

A Swift macro driven auto-mocking library.
MIT License
199 stars 14 forks source link

feat: require explicit mocking of void functions #28

Closed Kolos65 closed 3 months ago

Kolos65 commented 3 months ago

As @xmanu pointed out in #15 and proposed in #25 the current implementation does not require the explicit mocking of void functions. This makes the current implementation inconsistent as it otherwise requires explicit mocking for every other member.

This PR addresses this issue and makes the implementation consistent by requiring explicit mocking for void functions too. In addition, it adds a helper that makes it possible to write:

given(mock).someVoidFunc().willReturn()

instead of:

given(mock).someVoidFunc().willReturn(())

Support for an opt-in "relaxed mode" could be added in the future which would eliminate the need for explicit mocking in case of return values expressible by some literal (like optionals).

xmanu commented 3 months ago

Strict mode works great! We have adopted this in our project and this is a great addition! Thank you!