testcode 작성 시 메소드명만으로는 자세하게 구별할수가 없다.
따라서 설명 및 이름 같은 것을 붙여주어 구분하기 쉽게 한다.
junit4 사용 시
: junit4는 설명을 달기 위해서 따로 annotation을 만들어야한다.
package me.whiteship.restapi.common;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD) // 붙일수 있는 target은 메소드!!
@Retention(RetentionPolicy.SOURCE) // 이 애노테이션을 붙인 코드를 어디까지 가져갈것인가??
public @interface TestDescription {
String value();
}
junit5 사용 시
: junit5에서는 decription annotation이 따로 존재한다.
@DisplayName("test successful")
'JAVA' 카테고리의 다른 글
parameter를 이용한 test code (0) | 2022.07.26 |
---|---|
error serializer (0) | 2022.07.11 |
spring boot build 와 실행 (0) | 2022.07.06 |
String vs StringBuffer vs StringBuilder (0) | 2022.07.05 |
spring boot 프로젝트 생성과 사용 이유 (0) | 2022.07.04 |