create new junit rule: should use shouldFail not try/catch
Brought to you by:
chrismair
create new junit rule: should use shouldFail not try/catch
CodeNarc: Should use shouldFail
should fail:
try {
foo()
fail("Expected Exception");
} catch (IllegalStateException e) {
// leer
}
should fail:
try {
foo()
fail("Expected Exception");
} catch (IllegalStateException e) {
assertEquals(e.message, "...")
}
should fail:
try {
foo()
fail("Expected Exception");
} catch (IllegalStateException e) {
assertEquals("...", e.message)
}
should pass:
try {
foo()
fail("Expected Exception");
} catch (NullPointerException e) {
// OK
} catch (IllegalStateException e) {
assertEquals("...", e.message)
}