@Test public void testNoAssertionsTestComplete() { testComplete(); }
@Test public void testTestCompleteCalledMultipleTimes() { executor.execute(() -> { assertEquals("foo", "foo"); testComplete(); try { testComplete(); } catch (IllegalStateException e) { //OK } }); await(); }
@Test public void testAssertionOKTestComplete() { assertEquals("foo", "foo"); testComplete(); }
@Test public void testFailFromOtherThread() { String msg = "too many aardvarks!"; executor.execute(() -> { fail(msg); testComplete(); }); try { await(); } catch (AssertionError error) { assertTrue(error.getMessage().equals(msg)); } }
@Test public void testAssertionPassedFromOtherThread() { executor.execute(() -> { assertEquals("foo", "foo"); testComplete(); }); await(); }
@Test public void testAssertionFailedFromOtherThread() { executor.execute(() -> { assertEquals("foo", "bar"); testComplete(); }); try { await(); } catch (ComparisonFailure error) { assertTrue(error.getMessage().startsWith("expected:")); } }
@Test public void testAssertionFailedFromMainThread() { try { assertEquals("foo", "bar"); } catch (ComparisonFailure error) { assertTrue(error.getMessage().startsWith("expected:")); } testComplete(); }
@Test public void testSuccessfulCompletion() { executor.execute(() -> { assertEquals("foo", "foo"); assertFalse(false); testComplete(); }); await(); }
@Test public void testAssertionPassedFromMainThread() { assertEquals("foo", "foo"); testComplete(); await(); }
@Test public void testAwaitCalledMultipleTimes() { executor.execute(() -> { assertEquals("foo", "foo"); testComplete(); }); await(); try { await(); } catch (IllegalStateException e) { //OK } }
@Test public void testAssertionFailedFromOtherThreadAwaitBeforeAssertAndTestComplete() { executor.execute(() -> { //Pause to make sure await() is called before assertion and testComplete try { Thread.sleep(1000); } catch (InterruptedException e) { fail(e.getMessage()); } assertEquals("foo", "bar"); testComplete(); }); try { await(); } catch (ComparisonFailure error) { assertTrue(error.getMessage().startsWith("expected:")); } }
@Test public void testAssertionFailedFromOtherThreadForgotToCallAwait() throws Exception { executor.execute(() -> { assertEquals("foo", "bar"); testComplete(); }); Thread.sleep(500); try { super.afterAsyncTestBase(); fail("Should throw exception"); } catch (IllegalStateException e) { // OK } finally { // Cancel the error condition clearThrown(); } }
@Test public void testAssertionFailedFromMainThreadWithNoTestComplete() { try { assertEquals("foo", "bar"); } catch (AssertionError e) { // OK testComplete(); try { super.afterAsyncTestBase(); } catch (IllegalStateException e2) { fail("Should not throw exception"); } finally { // Cancel the error condition clearThrown(); } } }
@Test public void testAssertionOKTestComplete() { assertEquals("foo", "foo"); testComplete(); }
@Test public void testAssertionPassedFromOtherThread() { executor.execute(() -> { assertEquals("foo", "foo"); testComplete(); }); await(); }
@Test public void testAssertionFailedFromMainThread() { try { assertEquals("foo", "bar"); } catch (ComparisonFailure error) { assertTrue(error.getMessage().startsWith("expected:")); } testComplete(); }
@Test public void testSuccessfulCompletion() { executor.execute(() -> { assertEquals("foo", "foo"); assertFalse(false); testComplete(); }); await(); }
@Test public void testAssertionFailedFromOtherThread() { executor.execute(() -> { assertEquals("foo", "bar"); testComplete(); }); try { await(); } catch (ComparisonFailure error) { assertTrue(error.getMessage().startsWith("expected:")); } }
@Test public void testAssertionPassedFromMainThread() { assertEquals("foo", "foo"); testComplete(); await(); }
@Test public void testAwaitCalledMultipleTimes() { executor.execute(() -> { assertEquals("foo", "foo"); testComplete(); }); await(); try { await(); } catch (IllegalStateException e) { //OK } }