I have the following test:
@Test(expected=ArithmeticException.class)
public void divideByZero() {
int n = 2 / 1;
}
as seen here.
I would like to add a message that will print if this test fails.
For instance if I was doing an Assertion test, I would do the following to add a message:
@Test public void assertFail(){
Assert.fail("This is the error message I want printed.");
Assert.assertEquals(true, false);
}
The second example should print out “This is the error message I want printed.”. How do I set the first example message text?
I don’t think you can easily, but this guy seems to have partially worked his way around it.