title: How can I use PowerMock to mock final classes in an SBT project
body: <p>PowerMock doesn't have ScalaTest support, so I'm trying to use JUnit to run my ScalaTest classes, using <code>@RunWith[classOf[JUnitRunner]]</code>. Using Maven, you can configure the javaagent module to eagerly load to support this, as detailed in <a href="https://code.google.com/p/powermock/wiki/PowerMockAgent" rel="nofollow">the PowerMock wiki</a>. What do I need to do in SBT to get the same result?</p>
  
  <pre><code>name := "my-project"
  
  version := "1.0"
  
  scalaVersion := "2.10.2"
  
  libraryDependencies ++= Seq(
      // ... other dependencies above ...
      "org.powermock" % "powermock-api-mockito" % "1.5.1" % "test",
      "org.powermock" % "powermock-module-javaagent" % "1.5.1" % "test",
      "org.powermock" % "powermock-module-junit4-rule-agent" % "1.5.1" % "test",
      "com.novocode" % "junit-interface" % "0.10" % "test-&gt;default"
  )
  </code></pre>
  
  <p>As shown, this project has errors:</p>
  
  <pre><code>[error] Caused by: java.lang.IllegalStateException: PowerMockRule can only be used with the system classloader but was loaded by sbt.classpath.ClasspathUtilities$$anon$1@1cee593
  [error]     at org.powermock.modules.junit4.rule.PowerMockRule.&lt;clinit&gt;(PowerMockRule.java:28)
  [error]     ... 55 more
  </code></pre>
  
  <p>It appears SBT has its own classloader for running tests that is conflicting with what PowerMock needs to do.</p>