I have several tests cases in a list using failsafe and Junit as per below:
@Test
public void testResults() {
for (TestCase test : TestCaseList) {
int result = test.getActualResult();
int expected = test.getExpectedResult();
if (result != expected) {
System.out.println("Failed test " + test.getTestInfo());
}
assertEquals(result, expected);
}
}
I want the report something like :
Failed test <test description here>
java.lang.AssertionError:
Expected: is <4>
but: was <2>
Instead of just:
java.lang.AssertionError:
Expected: is <4>
but: was <2>
Is there a way to do that with Junit or other framework?
You can add a message to the assert:
This creates the following report: