java.lang.NoClassDefFoundError: org/scalatest/tools/Runner for tests in the shared project of a sbt-scalajs-crossproject
I'm getting the following exception when trying to run a test in any of the "shared" parts of my multi-target Scala projects. These tests do run when I run them with sbt.
java.lang.NoClassDefFoundError: org/scalatest/tools/Runner
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:133)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:27)
Caused by: java.lang.ClassNotFoundException: org.scalatest.tools.Runner
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 2 more
The command run is
/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/bin/java -Dvisualvm.id=116116752477305 "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=64148:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Users/rwillems/Library/Application Support/JetBrains/IdeaIC2020.1/plugins/Scala/lib/runners.jar:/Users/rwillems/Documents/GithubSources/Blender/languageServer/js/target/scala-2.13/test-classes:/Users/rwillems/Documents/GithubSources/Blender/languageServer/js/target/scala-2.13/classes:/Users/rwillems/Documents/GithubSources/Blender/LSPProtocol/js/target/scala-2.13/test-classes:/Users/rwillems/Documents/GithubSources/Blender/LSPProtocol/js/target/scala-2.13/classes:/Users/rwillems/Documents/GithubSources/Blender/LSPProtocol/shared/target/test-classes:/Users/rwillems/Documents/GithubSources/Blender/LSPProtocol/shared/target/classes:/Users/rwillems/Documents/GithubSources/Blender/editorParser/jvm/target/scala-2.13/test-classes:/Users/rwillems/Documents/GithubSources/Blender/editorParser/jvm/target/scala-2.13/classes:/Users/rwillems/Documents/GithubSources/Blender/editorParser/shared/target/test-classes:/Users/rwillems/Documents/GithubSources/Blender/editorParser/shared/target/classes:/Users/rwillems/Documents/GithubSources/Blender/editorParser/js/target/scala-2.13/test-classes:/Users/rwillems/Documents/GithubSources/Blender/editorParser/js/target/scala-2.13/classes:/Users/rwillems/Documents/GithubSources/Blender/languageServer/shared/target/test-classes:/Users/rwillems/Documents/GithubSources/Blender/languageServer/shared/target/classes:/Users/rwillems/Documents/GithubSources/Blender/LSPProtocol/jvm/target/scala-2.13/test-classes:/Users/rwillems/Documents/GithubSources/Blender/LSPProtocol/jvm/target/scala-2.13/classes:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/malliina/play-functional_sjs1_2.13/2.8.1/play-functional_sjs1_2.13-2.8.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/malliina/play-json_sjs1_2.13/2.8.1/play-json_sjs1_2.13-2.8.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.13/1.0.1/scalajs-library_2.13-1.0.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-test-bridge_2.13/1.0.1/scalajs-test-bridge_2.13-1.0.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-test-interface_2.13/1.0.1/scalajs-test-interface_2.13-1.0.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.1/scala-library-2.13.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.13.1/scala-reflect-2.13.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scalactic/scalactic_sjs1_2.13/3.1.1/scalactic_sjs1_2.13-3.1.1.jar:/Users/rwillems/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scalatest/scalatest_sjs1_2.13/3.1.1/scalatest_sjs1_2.13-3.1.1.jar" org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner -s miksilo.languageServer.server.ExampleExpressionLanguageTest -C org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestReporter -showProgressMessages true
请先登录再写评论。
Same here! I can't find why. The same test runs just fine by sbt shell or just console.
This is because for some reason the default configuration that is picked uses the JS project to run the test with instead of the JVM project. You can still run the test by adapting the configuration. However, it would be great if we can get a fix that makes the JVM project the default one for running tests, so we don't have to adapt the configuration for every single test we want to run.
keyboardDrummer Could you explain how to "adapt the configuration" or point to the documentation?