Java
- 11 ответов
- 0 вопросов
7
Вклад в тег
fail();
import org.junit.Test;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.fail;
public class ExampleTest {
private void exceptionMethod() throws Exception {
throw new RuntimeException("test");
}
@Test
public void test() {
try {
exceptionMethod();
fail("Impossible");
} catch (Exception e) {
assertEquals("Checks class", RuntimeException.class, e.getClass());
assertEquals("Checks message", "test", e.getMessage());
}
}
}