Open full view…

Spock without Mockito

Sat, 16 Sep 2017 09:02:33 GMT

Hi. Is it possible add template for groovy spock without mockito?

Sat, 16 Sep 2017 15:26:18 GMT

Hi stigmaleon, I would like to give the users the option to create new templates, possibly from existing ones and customize them as they wish. I don't think I can push that feature any time soon. As a short term solution, if you would like to add support for a different mocking framework, please let me know. I might be able to pull it off quickly. Adding a template with no mocking support seems less appealing to me. I think that adding an option to avoid mock generation when the user invokes any template might be useful and may address your needs. By the way, mocks should not be generated by any template, if there is no need to. Identifying when there is a need to generate mocks can be tricky and not all users may agree if a mock should or should not be generated for a given use case. If you find a use case where you think its obvious that mocks should not be generated for, please let me know.

Wed, 26 Sep 2018 06:20:16 GMT

What do you mean by "template without mocking support"? Spock has its own built-in mocking features. Not using Mockito is the default case for Spock users, thus this question makes a lot of sense IMO. I think @stigmalion likes to get Spock mocks generated instead of Mockito mocks.

Wed, 26 Sep 2018 12:12:53 GMT

Thanks for the clarification @kriegaex! Yes this defiantly makes sense. I may have misunderstood the request to swap the mocking framework ( _Spock MockingApi_ instead of _Mockito_) as a request to ditch the mocking functionality from generated Spock tests. I'll prioritize this feature request. The main difficulty here is to replace Mockito's auto injection functionality (using @InjectMocks ) with explicit initialization of the tested class, while trying to support various initialization patterns ( setters, constructors, private members - injected by DI frameworks or static factory methods)