title: Using Gradle test fixtures with PowerMock
body: <p>I am using PowerMock to verify a static call to JavaCC in a Gradle task.</p>
  
  <p>In my @Before annotated method (I'm using JUnit4 and Mockito, BTW), I have this:</p>
  
  <pre><code>Project project = ProjectBuilder.builder().build();
  </code></pre>
  
  <p>When I run any test case in this class annotated with</p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  </code></pre>
  
  <p>I get the following:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class org.gradle.testfixtures.internal.ProjectBuilderImpl
  at org.gradle.testfixtures.ProjectBuilder.&lt;init&gt;(ProjectBuilder.java:46)
  at org.gradle.testfixtures.ProjectBuilder.builder(ProjectBuilder.java:54)
  at ca.coglinc.gradle.plugins.javacc.CompileJavaccTaskTest.setUp(CompileJavaccTaskTest.java:43)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:132)
  at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:95)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
  at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
  at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
  at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
  at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
  at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
  at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:104)
  at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
  at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  </code></pre>
  
  <p>I think I am missing the Gradle runtime configuration on my test classpath, but can not find how to fix it. Removing the PowerMockRunner, my tests run correctly, but then I can't have a test that depends on PowerMock (I know stuff should be testable without requiring PowerMock, but I'm not writing JavaCC and still want to verify that it's called with some parameters). Any ideas?</p>