Junit4
[Junit4] @Test expected 예상한 예외가 발생하는 지 여부
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();
}
}