awaitCond = awaitCond with better error reporting, see #3168

This commit is contained in:
Patrik Nordwall 2013-03-22 18:33:14 +01:00
parent d49b8aa47c
commit 118917d2be
6 changed files with 130 additions and 31 deletions

View file

@ -187,6 +187,24 @@ public class TestKitDocTest {
}};
//#test-awaitCond
}
@Test
public void demonstrateAwaitAssert() {
//#test-awaitAssert
new JavaTestKit(system) {{
getRef().tell(42, null);
new AwaitAssert(
duration("1 second"), // maximum wait time
duration("100 millis") // interval at which to check the condition
) {
// do not put code outside this method, will run afterwards
protected void check() {
assertEquals(msgAvailable(), true);
}
};
}};
//#test-awaitAssert
}
@Test
@SuppressWarnings("unchecked") // due to generic varargs

View file

@ -282,6 +282,13 @@ code blocks:
reception, the embedded condition can compute the boolean result from
anything in scope.
* **AwaitAssert**
.. includecode:: code/docs/testkit/TestKitDocTest.java#test-awaitAssert
This general construct is not connected with the test kits message
reception, the embedded assert can check anything in scope.
There are also cases where not all messages sent to the test kit are actually
relevant to the test, but removing them would mean altering the actors under
test. For this purpose it is possible to ignore certain messages: