Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij will not run ScalaTests - "Incompatible Class Change Error"

I'm trying to run tests for an sbt-based Scala application in intellij. But I get the following error which I'm not sure how to fix:

Testing started at 21:07 ...
java.lang.IncompatibleClassChangeError: Found class scala.collection.mutable.ArrayOps, but interface was expected
    at org.scalatest.tools.Runner$.checkArgsForValidity(Runner.scala:895)
    at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:729)
    at org.scalatest.tools.Runner$.run(Runner.scala:711)
    at org.scalatest.tools.Runner.run(Runner.scala)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:144)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

When I decorate my classes with the Junit runner attribute they work fine (and it's actually a much better run in terms of the visuals):

@RunWith(classOf[JUnitRunner])
like image 279
Nick Avatar asked Jun 15 '13 20:06

Nick


1 Answers

I got the same error when trying to run tests for my Play Framework app. Drilling down into the stack trace, I found that the problem class was FakeRequest, which is in the play-test library. I had two different versions of the library, one for Play 2.4 and one for 2.3. I was able to resolve this issue by removing the play-test version for Play 2.3 (open Module Settings -> Libraries -> find and delete the bad dependency).

Your issue is probably with some other problematic dependency, but following the same steps as above may help fix it.

like image 200
user2904595 Avatar answered Sep 24 '22 10:09

user2904595