JAVA
testcode 작성 시 description
응디
2022. 7. 11. 16:55
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")