title: JUnit test case failure with JMockit java.lang.IllegalStateException: Invalid context for the recording of expectations
body: <pre><code>@Test
  public void testGetOnlyNewPartitions() throws Exception {
      setUp();
      new Expectations(){
          HiveUtil hiveUtil;
          {
              HiveUtil.getInstance(); returns(hiveUtil);
              hiveUtil.getAllpartitions(oldTable); returns(oldPartitions);
              hiveUtil.getAllpartitions(newTable); returns(newPartitions);
          }
      };
      PartitionFilter partitionFilter = new PartitionFilter(oldTable, newTable, HiveUtil.getInstance());
  }
  </code></pre>
  
  <p>I am unit testing the class PartitionFilter, which uses a singleton class HiveUtil.</p>
  
  <p>My test case is failing with the error "java.lang.IllegalStateException: Invalid context for the recording of expectations" while running. Any explanation on why this is happening?</p>
  
  <p>This is the relevant part of my pom.xml:</p>
  
  <pre><code>&lt;dependency&gt;
           &lt;groupId&gt;org.jmockit&lt;/groupId&gt;
           &lt;artifactId&gt;jmockit&lt;/artifactId&gt;
           &lt;version&gt;1.13&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.11&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I have tried to put the jmockit dependency before the junit dependency in the pom. That didn't work.</p>
  
  <p>Some more research suggested that I was not using the @RunWith(JMockit.class) annotation at the beginning of the class.
  However, when I tried to use it, I was presented with the error "Class cannot be resolved to a type". I made all the relevant imports.</p>
  
  <pre><code>import static org.junit.Assert.assertEquals;
  
  import org.junit.Test;
  import org.junit.runner.*;
  
  import mockit.*;
  import mockit.integration.junit4.*;
  import junit.framework.TestCase;
  </code></pre>
  
  <p>What am I doing wrong?</p>