0

I would like be able to receive meaningful errors, for example

Set set = new HashSet();
await().until(() -> set.contains("foo"));
// during waiting
set.add("bar")
// after timeout
"Condition 'foo' should be in set=['bar'] not fulfilled

I can write

await().alias("'foo' should be in set").until(() -> set.contains("foo"));

and get

"Condition with alias 'foo' should be in set not fulfilled

But I would like to see set content when condition was timeouted

Stephen Cleary
  • 437,863
  • 77
  • 675
  • 810
michaldo
  • 4,195
  • 1
  • 39
  • 65

1 Answers1

0

It should be possible by setting a conditionEvaluationListener (awaitility/awaitility#102):

await()
    .conditionEvaluationListener(new ConditionEvaluationListener() {
      @Override public void conditionEvaluated(final EvaluatedCondition condition) {}
      @Override public void onTimeout(final TimeoutEvent event) {
        System.error.println("Timeout waiting for 'foo'. Set contains: " + set);
      }
    })
    .util(() -> set.contains("foo"));

You might also find this old Google Groups thread helpful: Custom messages or method calls on success and timeout

knittl
  • 246,190
  • 53
  • 318
  • 364