9

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])
Dylan Corriveau
  • 2,561
  • 4
  • 29
  • 36
Nick
  • 1,845
  • 3
  • 15
  • 22

3 Answers3

2

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.

user2904595
  • 21
  • 1
  • 3
0

This seems to be a problem with scala test runner framework. I had come across the same problem; eventually like you suggested end up using junit test runner to make it work. But the problem in my case was it was pulling in a transitive dependency and no such class error.

0

Make sure the libraries what you are using for the JUnitRunner are same. Most of the times “Incompatible Class Change Error” occurs because of backward compatibility. And also have a look at scala library jar at the time of compiling and running.

Jet
  • 3,018
  • 4
  • 33
  • 48