@Retention(value=RUNTIME) @Target(value={TYPE,METHOD}) @Repeatable(value=Use.Container.class) public @interface Use
Basic example:
class ListExtensions { static avg(List list) { list.sum() / list.size() } } class MySpec extends Specification { @Use(ListExtensions) def "can use avg() method"() { expect: [1, 2, 3].avg() == 2 } }
One use case for this feature is the stubbing of dynamic methods which are usually provided by the runtime environment (e.g. Grails).
Note: @Use has no effect when applied to a helper method. However, when applied to a spec class it will also affect its helper methods.
Note: If this extension is applied on the Specification, then it will use
ExecutionMode.SAME_THREAD
for the whole Spec.
public abstract Class[] value