@Retention(value=RUNTIME)
@Target(value={TYPE,METHOD})
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.
| Modifier and Type | Required Element and Description |
|---|---|
java.lang.Class[] |
value |
Copyright © 2013. All rights reserved