JUnit
Exception test
@Rule어노테이션을 이용.ExpectedException에 원하는 Exception 클래스 추가expectexpectMessageexpectCause
public class ExceptionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
public void nullPointExceptionTest() throws Exception {
expectedException.expect(NullPointerException.class);
// ... Something code
String a = null;
a.equals("b");
}
}