为什么在 IntelliJ 中 运行 Scala 2.13 测试时出现此错误,但在 Scala 2.12 中却没有?
Why am I getting this error when running Scala 2.13 tests in IntelliJ, but not with Scala 2.12?
当我尝试在 IntelliJ (2019.1)、Scala IntelliJ 插件 v2019.1.8 和 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(DispatchReporter.scala:249)
at org.scalatest.DispatchReporter$Propagator.$anonfun$run$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)
以下是我的 Gradle 依赖项:
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'
}
当我将依赖项更改为 Scala 2.12.x 时,测试在 IntelliJ 中正确执行,没有错误。这是怎么回事?
更新:这已在插件版本 2019.1.9 中 fixed。
可能需要针对 2.13 更新 IntelliJ Scala 插件。同时通过选中测试 Edit configuration...
. According to Dmitrii Naumenko:
下的复选框 Use sbt
和 Use UI with sbt
来尝试解决方法
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
关于 Gradle,尝试配置委托给 Gradle Test Runner
- 删除现有的 ScalaTest 运行程序
- 转到
Build, Execution, Deployment | Build Tools | Gradle | Runner
- Select 复选框
Delegate IDE build/run actions to Gradle
- 选择
Gradle Test Runner
当我尝试在 IntelliJ (2019.1)、Scala IntelliJ 插件 v2019.1.8 和 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(DispatchReporter.scala:249)
at org.scalatest.DispatchReporter$Propagator.$anonfun$run$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)
以下是我的 Gradle 依赖项:
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'
}
当我将依赖项更改为 Scala 2.12.x 时,测试在 IntelliJ 中正确执行,没有错误。这是怎么回事?
更新:这已在插件版本 2019.1.9 中 fixed。
可能需要针对 2.13 更新 IntelliJ Scala 插件。同时通过选中测试 Edit configuration...
. According to Dmitrii Naumenko:
Use sbt
和 Use UI with sbt
来尝试解决方法
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
关于 Gradle,尝试配置委托给 Gradle Test Runner
- 删除现有的 ScalaTest 运行程序
- 转到
Build, Execution, Deployment | Build Tools | Gradle | Runner
- Select 复选框
Delegate IDE build/run actions to Gradle
- 选择
Gradle Test Runner