@Test(timeout = 2000) public void exceptionIgnoringWorksForHamcrestMatchers() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).with().ignoreExceptionsMatching(instanceOf(RuntimeException.class)).until(conditionsThatIsThrowingAnExceptionForATime(IllegalArgumentException.class)); }
@Test(timeout = 2000) public void assertionErrorIgnoringWorksForHamcrestMatchers() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).with().ignoreExceptionsMatching(instanceOf(AssertionError.class)).until(conditionsThatIsThrowingAnExceptionForATime(AssertionError.class)); }
@Test(timeout = 2000) public void exceptionsDuringEvaluationAreReportedByDefault() { exception.expect(RuntimeException.class); exception.expectMessage(is("Repository value is not 1")); new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).with().until(conditionsThatIsThrowingAnExceptionForATime(RuntimeException.class)); }
@Test public void awaitilityThrowsIllegalStateExceptionWhenTimeoutIsEqualToPollDelay() { exception.expect(IllegalStateException.class); exception.expectMessage(is("Timeout (200 milliseconds) must be greater than the poll delay (200 milliseconds).")); with().with().pollDelay(20, MILLISECONDS).pollDelay(200, MILLISECONDS).await().atMost(200, MILLISECONDS).until(fakeRepositoryValueEqualsOne()); }
@Test(timeout = 2000) public void noIgnoredExceptionsHavePrecedenceOverStaticallyDefinedExceptionIgnorer() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Repository value is not 1"); new Asynch(fakeRepository).perform(); Awaitility.ignoreExceptionsByDefaultMatching(instanceOf(RuntimeException.class)); await().atMost(1000, MILLISECONDS).with().ignoreNoExceptions().until(conditionsThatIsThrowingAnExceptionForATime(IllegalArgumentException.class)); }
@Test(timeout = 2000) public void exceptionIgnoringWorksForPredicates() { new Asynch(fakeRepository).perform(); await().atMost(1000, MILLISECONDS).with().ignoreExceptionsMatching(new Predicate<Throwable>() { public boolean matches(Throwable e) { return e instanceof RuntimeException; } }).until(conditionsThatIsThrowingAnExceptionForATime(IllegalArgumentException.class)); }