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