1. 程式人生 > >JUnit Assert方法總結

JUnit Assert方法總結

doc isn class unit face oid 判斷 static 成功

技術分享

assertTrue with error message

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”。

assertTrue without error message

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

JUnit Assert方法總結