Spock test without extending the Specification class - annotations?

625 views
Skip to first unread message

Juraj Martinka

unread,
Feb 15, 2014, 4:20:38 AM2/15/14
to spockfr...@googlegroups.com
Hi, 

I wonder if it's possible to create spock test without extension of Specification class - something like @Test junit annotation or similar.

My use case: 
I have a hierarchy of abstract test classes written in java (and placed in external maven module) which I would like to extend instead of Specification to reuse their logic.
Since java (groovy) does not allow multiple inheritance I'm struggling how to achieve this goal.
As far as I've seen all spock tests extend Specification class and there is no other way how to create spock test.
I'm not sure if this problem relates to https://code.google.com/p/spock/issues/detail?id=218, but that one seems a little bit different to me.

To sum up: it would be nice to have something like @Specification annotation which would serve as an alternative method for defining the spock test (instead of extending the Specification class).

Thanks for the answer(s)!

pnie...@gmail.com

unread,
Feb 15, 2014, 10:43:17 AM2/15/14
to spockfr...@googlegroups.com
All specs have to extend `Specification`, directly or indirectly. This isn’t going to change. Perhaps we can one day add mixin support and allow to mix in a JUnit base class, but it’s too early to say.

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spockframewor...@googlegroups.com.
To post to this group, send email to spockfr...@googlegroups.com.
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages