얼마동안 메서드를 실행시킬 것인지 정하고 초과시 메서드 실행을 실패로 중단시킨다.
@Test
@DisplayName("스터디 시작")
void create_new_study()
{
assertTimeout(Duration.ofSeconds(10), () -> {
new Study(10);
Thread.sleep(300);
});
}
https://www.daleseo.com/java8-duration-period/
[Java8 Time API] Duration과 Period 사용법 (+ChronoUnit)
Engineering Blog by Dale Seo
www.daleseo.com
'JAVA' 카테고리의 다른 글
interface를 상속받은 Abstract class를 상속받는 이유. (0) | 2022.11.17 |
---|---|
java10 _ var 키워드 (0) | 2022.11.15 |
serialVersionUID와 @SuppressWarning("serial")처리 (0) | 2022.11.14 |
Reflection (0) | 2022.09.07 |
Apache Ant (0) | 2022.08.19 |