Код: Выделить всё
public Horse(String name, double speed, double distance) {
if (isNull(name)) {
throw new IllegalArgumentException("Name cannot be null.");
} else if (name.isBlank()) {
throw new IllegalArgumentException("Name cannot be blank.");
}
if (speed < 0) {
throw new IllegalArgumentException("Speed cannot be negative.");
}
if (distance < 0) {
throw new IllegalArgumentException("Distance cannot be negative.");
}
this.name = name;
this.speed = speed;
this.distance = distance;
}
public Horse(String name, double speed) {
this(name, speed, 0);
}
Код: Выделить всё
@ParameterizedTest
@ValueSource(strings = {" ", "\t", " "})
void Constructor_Empty_String_Message(String s){
//given
//when
//then
try{
new Horse(s,0);
} catch (Exception e){
Assertions.assertEquals("Name cannot be blank.",e.toString());
}
}
Полная статистика исключений
Я думаю, что это проблема с параметром Resolver, но я не знаю, как ее исправить. .
Я использую Junit 5.8.0 и junit-jupiter-params 5.11.0-M2.
Подробнее здесь: https://stackoverflow.com/questions/787 ... va-lang-st
Мобильная версия