1 package junitparams; 2 3 import java.lang.annotation.Retention; 4 import java.lang.annotation.RetentionPolicy; 5 6 /** 7 * THE annotation for the test parameters. Use it to say that a method takes 8 * some parameters and define how to obtain them. 9 * 10 * @author Pawel Lipinski 11 */ 12 @Retention(RetentionPolicy.RUNTIME) 13 public @interface Parameters { 14 /** 15 * Parameter values defined as a String array. Each element in the array is 16 * a full parameter set, comma-separated or pipe-separated ('|'). 17 * The values must match the method parameters in order and type. 18 * Whitespace characters are trimmed (use source class or method if You need to provide such parameters) 19 * 20 * Example: <code>@Parameters({ 21 * "1, joe, 26.4, true", 22 * "2, angie, 37.2, false"})</code> 23 */ value()24 String[] value() default {}; 25 26 /** 27 * Parameter values defined externally. The specified class must have at 28 * least one public static method starting with <code>provide</code> 29 * returning <code>Object[]</code>. All such methods are used, so you can 30 * group your examples. The resulting array should contain parameter sets in 31 * its elements. Each parameter set must be another Object[] array, which 32 * contains parameter values in its elements. 33 * Example: <code>@Parameters(source = PeopleProvider.class)</code> 34 */ source()35 Class<?> source() default Void.class; 36 37 /** 38 * Parameter values returned by a method within the test class. This way you 39 * don't need additional classes and the test code may be a bit cleaner. The 40 * format of the data returned by the method is the same as for the source 41 * annotation class. 42 * Example: <code>@Parameters(method = "examplaryPeople")</code> 43 * 44 * You can use multiple methods to provide parameters - use comma to do it: 45 * Example: <code>@Parameters(method = "womenParams, menParams")</code> 46 */ method()47 String method() default ""; 48 } 49