Kau*_*mar 0 java testing testng unit-testing exception
如何为这段代码编写单元测试
if (!isVisible()) {
throw new IllegalStateException("Not in xyz page");
}
return this.isAttached(DOT_ID);
Run Code Online (Sandbox Code Playgroud)
如果isVisible()被模拟返回false那么如何编写异常语句的单元测试
使用testng,您可以像这样注释您的测试方法:
@Test(expectedExceptions = IllegalStateException.class,
expectedExceptionsMessageRegExp = "...")
public void your_test() {
[...]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31 次 |
| 最近记录: |