

초록 폴더는 test 패키지
파란 폴더는 main 패키지
*@ValueSource* /* 설명. 1. @ValueSource를 이용한 parameter value 목록 지정 */
@DisplayName("홀수 짝수 판별 테스트")
@ParameterizedTest
@ValueSource(ints ={1, 3, -1, 15, 123}) // 필기. given
void testIsOdd(int number){
// when
boolean result = NumberValidator.isOdd(number);
Assertions.assertTrue(result);
}
package com.haenin.parameterized.section01.params;
public class NumberValidator {
public static boolean isOdd(int number){
return number % 2 != 0 ? true: false;
}
}
@NullSource /* 설명. 2. @NullSource와 @EmptySource */
@DisplayName("null값 테스트")
@ParameterizedTest
@NullSource
void testIsNull(String input){
boolean result = StringValidator.isNull(input);
Assertions.assertTrue(result);
}
package com.haenin.parameterized.section01.params;
public class StringValidator {
public static boolean isNull(String input){
return input == null;
}
public static boolean isEmpty(String input) {
return "".equals(input);
}
}
@EmptySource @DisplayName("empty값 테스트")
@ParameterizedTest
@EmptySource
void testIsEmpty(String input){
boolean result = StringValidator.isEmpty(input);
Assertions.assertTrue(result);
}