Tuesday, May 21, 2013

How to fail test case in TestNG with Selenium

Q. How do I fail or report a failed test case?
Ans. You can use Assert statement to report a failure.

              org.testng.Assert.fail("Test Case Failed!");

you can use Assert in If Else statement to check for failure, quick example below, I am using selenium code snippet here!  
   
  if(convert.contains(blah)) 
 {
    Reporter.log("Pass");
 }
   else
 {
    org.testng.Assert.fail("Fail");
 }

No comments: