title: TestNG Test Case failing with JMockit "Invalid context for the recording of expectations"
body: <p>The following TestNG (6.3) test case generates the error "Invalid context for the recording of expectations"</p>
  
  <pre><code>@Listeners({ Initializer.class })
  public final class ClassUnderTestTest {
  
  private ClassUnderTest cut;
  
  @SuppressWarnings("unused")
  @BeforeMethod
  private void initialise() {
      cut = new ClassUnderTest();
  }
  
  @Test
  public void doSomething() {
      new Expectations() {
          MockedClass tmc;
          {
              tmc.doMethod("Hello"); result = "Hello";
          }
      };
      String result = cut.doSomething();
      assertEquals(result, "Hello");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The class under test is below.</p>
  
  <pre><code>public class ClassUnderTest {
  
  MockedClass service = new MockedClass();
  MockedInterface ifce = new MockedInterfaceImpl();
  
  public String doSomething() {
      return (String) service.doMethod("Hello");
  }
  
  public String doSomethingElse() {
      return (String) ifce.testMethod("Hello again");
  }
  }
  </code></pre>
  
  <p>I am making the assumption that because I am using the @Listeners annotation that I do not require the javaagent command line argument.  This assumption may be wrong....</p>
  
  <p>Can anyone point out what I have missed?</p>