...
Popper supports an extensible framework for specifying more elaborate algorithms for selecting test data. Instead of the public variables, we can define our own parameter supplier. Here is one (coded in Java) which supplies data between a first value and a last value. First the annotation definition (coded in Java):
| Code Block |
|---|
// Java
import net.saff.theories.methods.api.ParametersSuppliedBy;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@ParametersSuppliedBy(BetweenSupplier.class)
public @interface Between {
int first();
int last();
}
|
And the backing supplier (coded in Groovy):
| Code Block |
|---|
// Java import net.saff.theories.methods.api.*; import java.util.*; public class BetweenSupplierBetweenSupplierGroovy extends ParameterSupplier { @Override public List getValues(Object test, ParameterSignature sig) { Betweendef annotation = (Between) sig.getSupplierAnnotation();supplierAnnotation ArrayList list = new ArrayList(); for (int i = annotation.first(); i <= ..annotation.last(); i++) list.add(new Integer(i)); return list; } } |
Now our Groovy test example could become:
...