JUnit Assert方法總結
阿新 • • 發佈:2017-08-03
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 anAssertionError
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方法總結