in my Junit test, I use usually “AssertEquals” and when the test fails, the trace is properly displayed in the Failure trace of JUnit/eclipse
I would like to know how to get these trace to show it in a file?
@Test
public void testButtons() {
SelectionButton().ButtonFile();
assertEquals("selected button should be edit",FILE.EDIT,File.getSelectedItem);
}
how could I print/redirect the assert failure trace in a file ?
thanks
The
assertEqualsmethod of JUnit throws anAssertionErrorwithout a message on error. If you want to log more information on the failure you will have to catch theAssertionErrorlike in: