Junit中AssertTrue的使用


assertTrue

public static void assertTrue(String message,
                              boolean condition)
Asserts that a condition is true. If it isn't it throws an  AssertionError with the given message.

分析:

示例:

boolean value=webDriver.findElement(By.xpath("......")).isDisplay();//判断是否显示xx

assertTrue("Failed to go to the Login page", value);

如果value的值是true则运行成功,如果value的值是false则运行失败并打印出信息“Failed to go to the Login page”。

Parameters:
message - the identifying message for the  AssertionError ( null okay)
condition - condition to be checked

assertTrue

public static void assertTrue(boolean condition)
Asserts that a condition is true. If it isn't it throws an  AssertionError without a message.

 

Parameters:
condition - condition to be checked


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM