// Equivalent to "spyingOnRealObjects", but real implementations execute only on replay.
  @Test // Uses of JMockit API: 7
  public void dynamicPartialMocking() {
    final MockedClass mock = new MockedClass();

    // Mocks a real object:
    new Expectations(mock) {};

    // Optionally, you can record some invocations:
    new Expectations() {
      {
        mock.getSomeValue();
        result = 100;
      }
    };

    // When recording invocations on any mocked instance, partially mocked or not, real
    // implementations
    // are never executed, so this call would never throw an exception:
    new Expectations() {
      {
        mock.getItem(1);
        result = "an item";
      }
    };

    // Using the mock calls real methods, except for calls which match recorded expectations:
    mock.doSomething("one", true);
    mock.doSomething("two", false);

    assertEquals("one", mock.getItem(0));
    assertEquals("an item", mock.getItem(1));
    assertEquals(100, mock.getSomeValue());

    // Optionally, you can verify invocations to the dynamically mocked types/objects:
    new Verifications() {
      { // when verifying invocations, real implementations are never executed
        mock.doSomething("one", true);
        mock.doSomething("two", anyBoolean);
      }
    };
  }