Annotation Type InstancioSource
@Target({ANNOTATION_TYPE,METHOD})
@Retention(RUNTIME)
@Documented
@ArgumentsSource(org.instancio.junit.internal.InstancioSourceArgumentsProvider.class)
public @interface InstancioSource
Provides arguments for
@ParameterizedTest methods, supporting
multiple arguments per test run. Each argument will be a fully-populated
instance generated by Instancio.
Example usage:
@ExtendWith(InstancioExtension.class)
class ExampleTest {
@ParameterizedTest
@InstancioSource(samples = 3)
void someTestMethod(String s, int n, Person person) {
// ... use generated arguments
}
}
The above example will run the test method 3 times, each time with
a different set of arguments: a random string, a random integer, and
a randomly populated instance of the Person class.
- Since:
- 1.1.8
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintSpecifies the number of times to run the test, generating a new set of arguments each time.
-
Element Details
-
samples
@ExperimentalApi int samplesSpecifies the number of times to run the test, generating a new set of arguments each time.The default value is
0, which means the number will be determined from theKeys.INSTANCIO_SOURCE_SAMPLESsetting.- Returns:
- the number of samples to generate
- Since:
- 5.0.0
- Default:
0
-