I use TestNG for assertion, for example with this assertTrue
:
Assert.assertTrue(boolean b, String s)
If the assert is failed, then the String s will be printed out, and if assertion is passed, then no message is printed. I want to print a message in case the assert is passed anyway, so I write some thing like this:
// verify if additional info is saved
// do something
Assert.assertTrue(webDriver.findElement(By.name("CreatePostbox")).isDisplayed(), "Additional Information is not saved");
System.out.println("Additional information is saved");
...
So basically, if the assert is failed, then the message will be printed out as intended and test is aborted. But when the assert is passed, then the message in println will be printed out.
My question: is it a clean way to print message when the assert is passed? or is there a better way?