title: Mocking behaviour resets after each test with PowerMock
body: <p>I'm writing unit tests using PowerMock, mocking behaviour of some util classes. Defining behaviour once for test class (by @BeforeClass annotation) causes:</p>
  
  <ul>
  <li>first test invocation to return mocked value</li>
  <li>second test invocation to return real method return value</li>
  </ul>
  
  <p>Sample code:</p>
  
  <pre><code>import org.junit.Assert;
  import org.junit.BeforeClass;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.powermock.api.mockito.PowerMockito;
  import org.powermock.core.classloader.annotations.PrepareForTest;
  import org.powermock.modules.junit4.PowerMockRunner;
  
  @RunWith(PowerMockRunner.class)
  @PrepareForTest( {A.class, B.class})
  public class TestMockedMethods {
  
  private static B b;
  
  @BeforeClass
  public static void setUp() {
      PowerMockito.mockStatic(A.class);
      PowerMockito.when(A.getVal()).thenReturn("X");
  
      b = PowerMockito.mock(B.class);
      PowerMockito.when(b.getVal()).thenReturn("Y");
  }
  
  @Test
  public void test1() { // PASS
      Assert.assertEquals("X", A.getVal());
      Assert.assertEquals("Y", b.getVal());
  }
  
  @Test
  public void test2() { // FAIL
      Assert.assertEquals("X", A.getVal()); // actual="A"
      Assert.assertEquals("Y", b.getVal()); // actual="B"
  }
  
  }
  class A {
    static String getVal() {
      return "A";
    }
  }
  class B {
    String getVal() {
      return "B";
    }
  }
  </code></pre>
  
  <p>Any ideas why second test is failing?</p>