有没有可能让黄瓜测试失败?

4
下面的代码段比较了两个列表。 在我的步骤中,我使用if语句来检查destinationList是否为空,如果是,则测试正确,并且cucumber步骤应继续进行。
然而,如果到达else语句,我是否有办法使cucumber测试失败?
if (destinationList.isEmpty()) {
    System.out.println("This report is correct");

} else {
     System.out.println("This report is incorrect.");
     System.out.println("This list conatains the expected values of the report and their locations:");
     System.out.println("expected = "+sourceList);
     System.out.println("This list contains the actual value from this report and their locations:");
     System.out.println("actual = "+destinationList);
}
2个回答

4

2
或者,你可以不用在if语句中使用“fail”,而是直接使用“Assert.assertTrue(destinationList.isEmpty());”。 - AndyN

1
我找到了答案。 我最初尝试了 assert fail,但它没有起作用。 正确的语法是 Assert.fail();,我将其包含在我的 else 语句的底部。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接