상세 컨텐츠

본문 제목

[Junit4] @Test expected 예상한 예외가 발생하는 지 여부

Junit4

by kwanghyup 2020. 6. 17. 22:10

본문

import org.junit.*;

public class SampleTest {

    // 메소드가 특정 예외를 throw 하는지 여부 체크
    @Test(expected=IllegalArgumentException.class) // IllegalArgumentException 예외를 throw하면 테스트 성공 
    public void testException() {

        throw new IllegalArgumentException();
    }
}

관련글 더보기

댓글 영역