Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Make This Test case to Fail

I have a test case as shown below . it compares 2 data and returns PASS if both data is identical .

the issue is i want this test to fail if there is data mismatch

CODE is

WebElement TxtBoxContent = driver.findElement(By.id(WebelementID));

String Content = TxtBoxContent.getAttribute("value");

String ExcelData = Generic.getXlCellValue(xlpath, sheetName, rownum, cellnum);

Content.equals(ExcelData);

Reporter.log(LocationName+" Data Verification -- PASS",true);
like image 971
Santhosh S Avatar asked Dec 16 '22 01:12

Santhosh S


1 Answers

If you are on TestNg then to fail test case use below thow

Assert.fail();

or

Assert.fail("Write your custom error message");

Reporter.log() is for logging, it will not fail your test case.

like image 82
pavanraju Avatar answered Dec 18 '22 10:12

pavanraju