Код: Выделить всё
private static final String[] myParameters = {"a", "b", "c"};
// This fails with the message that `myParameters` isn't a recognized symbol, probably because it's not a valid Element for @ValueSource
@ParameterizedTest
@ValueSource(myParameters)
public void myTest(String param) {
// doesn't compile
}
// This fails with the message that "incompatible types: String[] cannot be converted to String"
@ParameterizedTest
@ValueSource(strings = myParameters)
public void myTest(String param) {
// doesn't compile
}
// This works fine, but I would need to duplicate the values of `strings` for each test
@ParameterizedTest
@ValueSource(strings = {"a", "b", "c"})
public void myTest(String param) {
// works fine, but its duplicative in terms of the @ValueSource parameter
}
[*]Тип аннотации ValueSource
[*]JUnit GitHub >
Подробнее здесь: https://stackoverflow.com/questions/761 ... a-paramete
Мобильная версия