20.12.30 22:12 작성
·
582
18
@ParameterizedTest
@MethodSource("paramsForTestFree")
public void testFree(int basePrice, int maxPrice, boolean isFree) {
// given
Event event = Event.builder()
.basePrice(basePrice)
.maxPrice(maxPrice)
.build();
// when
event.update();
// then
assertThat(event.isFree()).isEqualTo(isFree);
}
@ParameterizedTest
@MethodSource("paramsForTestOffline")
void testOffline(String location, boolean isOffline) {
// given
Event event = Event.builder()
.location(location)
.build();
// when
event.update();
// then
assertThat(event.isOffline()).isEqualTo(isOffline);
}
private static Stream<Arguments> paramsForTestFree() { // argument source method
return Stream.of(
Arguments.of(0,0, true),
Arguments.of(100, 0, false),
Arguments.of(0, 100, false),
Arguments.of(100, 200, false)
);
}
private static Stream<Arguments> paramsForTestOffline() { // argument source method
return Stream.of(
Arguments.of("강남", true),
Arguments.of(null, false),
Arguments.of(" ", false)
);
}
JUNIT5를 이용하시는분들에게 도움이 되었으면 좋겠습니다.