sampig / spock

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

Smarter mock injection #313

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Describe the enhancement you have in mind.

Can we introduce smarter mock injection into Spock? Something similar to 
Mockito's @InjectMocks functionality would be ideal.

Which particular problem would this enhancement solve for you?

When instantiating objects under specification, I frequently set mocked 
collaborators through constructors or via setter methods. This leads to extra 
boilerplate in my tests, and can lead to brittle tests and higher test 
maintenance.

Global Groovy Mocks are one option, but their usage is not quite as elegant as 
Mockito's solution, and they would not work in cases where the target object 
had two collaborators of the same type.

Please provide any additional information below. You can also assign
labels.

Original issue reported on code.google.com by robert.t...@googlemail.com on 26 May 2013 at 2:10