@Test(expected = RuntimeException.class) // Uses of JMockit API: 2
  public void stubVoidMethodsWithExceptions() {
    new Expectations() {
      {
        // void/non-void methods are handled the same way, with a consistent API:
        mockedList.clear();
        result = new RuntimeException();
      }
    };

    mockedList.clear();
  }
  @Test // Uses of JMockit API: 2
  public void stubbingVoidMethods() {
    // The API is consistent, so this is the same as for non-void methods:
    new Expectations() {
      {
        mockedList.clear();
        result = new RuntimeException();
      }
    };

    try {
      // Following throws RuntimeException:
      mockedList.clear();
      fail();
    } catch (RuntimeException ignore) {
    }
  }