Why am I getting this error when running Scala 2.1

2020-03-01 06:05发布

问题:

I am getting the following error when I try to run tests in IntelliJ (2019.1), Scala IntelliJ plugin v2019.1.8, with Scala 2.13:

Exception in thread "ScalaTest-dispatcher" java.lang.NoSuchMethodError: scala.collection.JavaConverters.seqAsJavaListConverter(Lscala/collection/Seq;)Lscala/collection/convert/Decorators$AsJava;
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.treeBuilder.ParallelTreeBuilder.getOrdinalList(ParallelTreeBuilder.java:21)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.treeBuilder.ParallelTreeBuilder$SuiteTree.<init>(ParallelTreeBuilder.java:92)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.treeBuilder.ParallelTreeBuilder.initRun(ParallelTreeBuilder.java:261)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestReporterWithLocation.apply(ScalaTestReporterWithLocation.java:59)
    at org.scalatest.DispatchReporter$Propagator.$anonfun$run$10(DispatchReporter.scala:249)
    at org.scalatest.DispatchReporter$Propagator.$anonfun$run$10$adapted(DispatchReporter.scala:248)
    at scala.collection.immutable.List.foreach(List.scala:312)
    at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:248)
    at java.lang.Thread.run(Thread.java:745)

The following are my Gradle dependencies:

dependencies {
    implementation 'org.scala-lang:scala-library:2.13.0'

    testImplementation 'org.scalatic:scalatic_2.13:3.0.8'
    testImplementation 'org.scalatest:scalatest_2.13:3.0.8'
}

When I change the dependencies to Scala 2.12.x, the tests execute correctly in IntelliJ without error. What is going on here?

回答1:

Update: This has been fixed in plugin version 2019.1.9.


It is possible IntelliJ Scala plugin needs to be updated for 2.13. Meanwhile try workaround by selecting the checkboxes Use sbt and Use UI with sbt under test's Edit configuration.... According to Dmitrii Naumenko:

This is fixed in the

  • 2019.1 EAP #2019.1.8.21
  • 2019.2 Nightly
  • Will be available soon in 2019.2 EAP and 2019.1 new Release

Regarding Gradle, try configuring to delegate to Gradle Test Runner

  1. Remove exising ScalaTest runners
  2. Go to Build, Execution, Deployment | Build Tools | Gradle | Runner
  3. Select the checkbox Delegate IDE build/run actions to Gradle
  4. Choose Gradle Test Runner