如何使此测试用例失败 [英] How to Make This Test case to Fail

查看:145
本文介绍了如何使此测试用例失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下所示的测试用例.它比较2个数据,如果两个数据相同,则返回PASS.

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是

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);

推荐答案

为了使测试失败,您可以养成在需要检查布尔值时编写断言的习惯

In order to make your test fail, you can put a habit of writing Assertions whenever you have something boolean to check

Assert.assertTrue(Content.equals(ExcelData));

如果您的测试应通过False条件,那么您的声明将变为

In case your Test should pass for a False condition, then your Assert would become

Assert.assertFalse(Content.equals(ExcelData));

这篇关于如何使此测试用例失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆