seanhenry / MockGenerator

An AppCode plugin to help generate Swift test doubles automatically.
GNU General Public License v3.0
71 stars 11 forks source link

Reset Spy between runs #20

Closed pikaboo closed 5 years ago

pikaboo commented 5 years ago

If i have multiple tests that use the same instance of mock, i get fails for the number of times a method was invoked for example

Need a reset method that will send the spy back to initial state

seanhenry commented 5 years ago

Hi @pikaboo

Thanks for this suggestion. One of the reasons this feature isn't there is because I would like to keep the generated code simple and in a handwritten style so that you can generate these test doubles without requiring the whole development team to adopt this plugin. Adding a reset method would make the generated code impossible to maintain without everyone using this plugin.

A simple solution to the problem is to just recreate the mock in the setUp or beforeEach part of your test run.

Another solution is to create your own template to generate your own mock objects (see here). The functionality isn't there yet but I will add that feature if you will use it.

seanhenry commented 5 years ago

I'm hoping you're ok with the above solution. If not, feel free to reopen this issue :)