Forgus / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Support creation of mocks outside the Spock context and allow to associate such a mock with a specification #305

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Spock should offer an API that allows
* Creating a mock outside a Specification instance (for example a bean instance 
managed by some container such as Spring, etc.)
* Associate such a mock with the current specification instance.

This would allow creating an integration test where complex interactions with 
external resources such as 3rd-party services (web service) can be mocked. This 
is often requried as these services are slow, accessible only with complex 
authentication, etc.

See also the forum discussion at 
https://groups.google.com/forum/?fromgroups=#!topic/spockframework/mKD4HD7tbEs

Original issue reported on code.google.com by Martin.A...@gmail.com on 27 Mar 2013 at 10:35

GoogleCodeExporter commented 8 years ago
When it comes to integration testing, an alternative (that I tend to prefer) is 
to hand-roll a fake object. However, I understand that opinions on this matter 
differ, and it shouldn't be too difficult to support this use case.

Original comment by pnied...@gmail.com on 27 Mar 2013 at 11:12

GoogleCodeExporter commented 8 years ago
I would be very interested in this feature and willing to help on the 
implementation. It would be awesome if we could do something like Springokito's 
@ReplaceWithMock 
https://bitbucket.org/kubek2k/springockito/wiki/springockito-annotations

Original comment by l.brueni...@googlemail.com on 10 Jul 2013 at 5:56