Spock extension extending the spring extension

40 views
Skip to first unread message

janbols

unread,
Jun 8, 2012, 5:47:18 PM6/8/12
to Spock Framework - User
Hi, i would like to make an extension that would only make sense doing
spring tests. It would add an extra bean to the aplication context.
However, how would I get hold of the application context within the
extension.
The only feasible way I think would be to subclass the
springextension. Or would there be anorher way?
Greetings
Jan Bols

Peter Niederwieser

unread,
Jun 9, 2012, 2:57:59 AM6/9/12
to spockfr...@googlegroups.com
A few ideas:
- provide a base class with a property of type `ApplicationContext` that gets injected by Spring
- require the user to declare a property of type `ApplicationContext` that gets injected by Spring
- use a Spring TestExecutionListener

Maybe the Spring extension could also provide a way for other extensions to grab the application context directly. I'm not sure if subclassing the SpringExtension is a solution, because the original extension would likely get triggered anyway, which could pose problems.

Cheers,
Peter
> --
> You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
> To post to this group, send email to spockfr...@googlegroups.com.
> To unsubscribe from this group, send email to spockframewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.
>

Jan Bols

unread,
Jun 9, 2012, 3:20:37 AM6/9/12
to spockfr...@googlegroups.com
I'll have a look at the TestExecutionListener and if that doesn't work, go for the 2nd solution. 
Thanks
Jan
Reply all
Reply to author
Forward
0 new messages