【问题标题】:Running specs2 test on IntelliJ throws InvocationTargetException在 IntelliJ 上运行 specs2 测试会引发 InvocationTargetException
【发布时间】:2021-03-16 03:36:30
【问题描述】:

我有使用 specs2 作为测试框架的 Scala Play 项目。我很难从 IntelliJ 运行测试。我收到以下错误:

InvocationTargetException for 'main' in org.specs2.NotifierRunner: null


Process finished with exit code 0

测试从sbt 成功运行。我见过很少有其他帖子说这可能是由于ScalaTestPlus,但我不使用ScalaTest

这是我的依赖项的样子

build.sbt

libraryDependencies ++= Seq(
  ws,
  guice,
  specs2 % Test,
...
)

project/plugins.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.6")

...

测试如下:

@RunWith(classOf[JUnitRunner])
class MyAppSpec extends PlaySpecification with Mockito {
...

【问题讨论】:

  • 您在sbt 中使用的命令是什么?
  • 您能否运行sbt> show externalDependencyClasspath 并检查什么是specs2 版本?你可能想试试specs2-core-4.10.5
  • 您使用什么运行配置来运行测试?检查jetbrains.com/help/idea/…
  • @TomerShetah 我只是在运行sbt test @Eric 我在show externalDependencyClasspath 上看不到specs2。我尝试添加dependencyOverrides += "org.specs2" % "specs2" % "3.7" % TestdependencyOverrides += "org.specs2" % "specs2-core" % "4.10.6" % Test 没有任何成功@Andrey 是的,我确实遵循了Jetbrains 文档中解释的配置

标签: scala intellij-idea playframework sbt specs2


【解决方案1】:

给还在苦苦挣扎的人留言,希望对你有帮助。

我遇到了同样的错误,这是因为我只是使用了带有 specs2 的不同 scala 版本。我将scala二进制版本指定为2.12,但导入使用2.11编译的specs2。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 1970-01-01
    • 2014-05-13
    • 2014-04-02
    • 1970-01-01
    相关资源
    最近更新 更多