Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class ArgumentsSourceParameterizedTest{
@ParameterizedTest
@ArgumentsSource(MyArgumentProvider.class)
void argumentSourceArgumentsStream(Person arg) {
assertNotNull(arg);
assertTrue(arg.getFullName().contains(" "));
assertFalse(arg.getAge() < 0);
}
static class MyArgumentProvider implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
Person personA = new Person("Ryosuke", "Uchitate", 27, Gender.MAN);
Person personB = new Person("Taro", "Uchitate", 20, Gender.MAN);
return Stream.of(personA, personB).map(Arguments::of);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment