How can I get the results of my JUnit assertions to be printed [to standard output]?
I have some tests like this:
@Test
public void test01()
{
Position
First, you have two issues not one. When an assertion fails, an AssertionError
exception is thrown. This prevents any assertion past this point from being checked. To address this you need to use an ErrorCollector.
Second, I do not believe there is any way built in to JUnit to do this. However, you could implement your own methods that wrap the assertions:
public static void assertNotNull(String description, Object object){
try{
Assert.assertNotNull(description, object);
System.out.println(description + " - passed");
}catch(AssertionError e){
System.out.println(description + " - failed");
throw e;
}
}