Hello guys I was wondering if this way of testing my exception is ok, i have this exception i need to throw in the second test annotation, im receiving as result a red evil
if your are using java 8, I would recommend to go for the AssertJ library
public void GTFRICreationTester_shouldFail() {
assertThatExceptionOfType(EXCEPTION_CLASS).isThrownBy(() -> { factory.createLocomotive(weirdProtocol, false, new Date()) })
.withMessage("MESSAGE")
.withMessageContaining("MESSAGE_CONTAINING")
.withNoCause();
}
with that solution you can at one verify exception type, with message etc.
for more reading, take a look at: http://joel-costigliola.github.io/assertj/assertj-core-features-highlight.html#exception-assertion