Lea*_*501 5 java exception awaitility
我有一些使用 Awaitility 库(https://mvnrepository.com/artifact/org.awaitility/awaitility/4.0.2)的功能测试,我需要的是用它运行一些代码,并在以下情况下执行一些操作条件失败,直到成功,或者时间超过 Awaitility 条件的限制。
到目前为止我有这个:
Awaitility.await().atMost(10, SECONDS).until(() -> {
try {
some code...
some assertions...
return true;
} catch (Throwable throwable) {
throwable.printStackTrace();
some more code...
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
如果超过 10 秒限制,此条件失败,我得到的结果是:
org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in myproject.class was not fulfilled within 10 seconds.
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能显示导致 Awaitility 条件未成功的真实代码异常,同时还具有在代码失败时运行某些代码的功能呢?
先感谢您。