Export to GitHub

spock - issue #389

Make spock.lang.Specification a Groovy trait


Posted on Feb 20, 2015 by Massive Kangaroo

Describe the enhancement you have in mind.

Would it be possible to implement Specification as a Groovy trait instead of an abstract class? (The abstract class could be part of a separate release to maintain support for versions of Groovy prior to 2.3).

Which particular problem would this enhancement solve for you?

I do a lot of work with Apache Camel, which requires all tests to extend the CamelTestSupport class. Since Spock requires extending from Specification, I am unable to write my Camel tests using Spock. And I think there are other projects that also expose test functionality via an abstract class that all tests must extend.

If Specification was a Groovy trait instead of an abstract class, then I could do this to write a spec for testing camel:

class MyCamelSpec extends CamelTestSupport implements Specification {...}

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

Comment #1

Posted on Feb 20, 2015 by Grumpy Cat

Thanks for the suggestion. This would be very difficult to pull off and is unlikely going to happen. Camel should really offer an alternative to the CamelTestSupport class, if it doesn't already (as the name of the class suggests).

Comment #2

Posted on Feb 20, 2015 by Massive Kangaroo

No worries. I really made the suggestion with very limited understanding of traits (just what I gleaned from Cedric Champeau's excellent JavaONE presentation), and thought it might be doable.

Status: New

Labels:
Type-Enhancement Module-Core