JUnit Assert方法总结
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JUnit Assert方法总结相关的知识,希望对你有一定的参考价值。
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方法总结的主要内容,如果未能解决你的问题,请参考以下文章