Sample code:
package ABC;
import org.testng.Assert;
import org.testng.annotations.Test;
public class Assertcheck
{
@Test
public void check() {
Assert.assertTrue(true, "testing my website");
}
}
Message parameter "testing my website" will get executed only if the Assert condition gets false. The message will appear in console.
But in the case of Assert condition passed, the message part will not get executed so you will not see any message in that case.
If you want to see the message in both the cases, you should use try-catch statement, something like:
try{
Assert.assertTrue(true, "testing my website");
//print your message for the case assert pass and/or perform any other event
}catch (Exception e){
//print your message for the case assert fails and/or perform any other event
loggerObj.debug("Assert Failed "+e.getMessage());
}
No comments:
Post a Comment