5

I have some functional test that make use of the Awaitility library (https://mvnrepository.com/artifact/org.awaitility/awaitility/4.0.2) what i need, is to run some code with it and also make some actions if the condition fails, until it became succesfully, or the time exceeds the limit of the Awaitility condition.

So far i have this:

Awaitility.await().atMost(10, SECONDS).until(() -> {
    try {
        some code...
        some assertions...

        return true;
    } catch (Throwable throwable) {
        throwable.printStackTrace();
        some more code...
        return false;
    }
});

what i get if this condition fails if exceeds the 10 seconds limit is:

org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in myproject.class was not fulfilled within 10 seconds.

So how can i show the real code exception that caused the Awaitility condition to not get successful, but also having the feature of running some code if the code fails?

thank you in advance.

Lea2501
  • 311
  • 6
  • 22

0 Answers0