在Intellij中运行Scala测试

在Intellij中运行Scala测试,scala,intellij-idea,specs2,Scala,Intellij Idea,Specs2,我试图在Intellij社区版13.1.3中运行Scala测试(specs2)。我得到以下错误: Connected to the target VM, address: '127.0.0.1:57980', transport: 'socket' 'Start' method is not found in MyNotifierRunner null Exception in thread "main" java.lang.reflect.InvocationTarge

我试图在Intellij社区版13.1.3中运行Scala测试(specs2)。我得到以下错误:

Connected to the target VM, address: '127.0.0.1:57980', transport: 'socket'

'Start' method is not found in MyNotifierRunner null

Exception in thread "main" java.lang.reflect.InvocationTargetException
    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:606)
Disconnected from the target VM, address: '127.0.0.1:57980', transport: 'socket'
    at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:123)
    at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:69)
Caused by: java.lang.NoSuchMethodError: org.specs2.matcher.MatchResult$.matchResultAsResult()Lorg/specs2/execute/AsResult;
    at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply$mcV$sp(ReportsDemographicsComponentTest.scala:14)
    at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
    at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
    at org.specs2.mutable.SideEffectingCreationPaths$$anonfun$executeBlock$1.apply$mcV$sp(FragmentsBuilder.scala:292)
    at org.specs2.mutable.SideEffectingCreationPaths$class.replay(FragmentsBuilder.scala:264)
    at org.specs2.mutable.Specification.replay(Specification.scala:12)
    at org.specs2.mutable.FragmentsBuilder$class.fragments(FragmentsBuilder.scala:27)
    at org.specs2.mutable.Specification.fragments(Specification.scala:12)
    at org.specs2.mutable.SpecificationLike$class.is(Specification.scala:14)
    at org.specs2.mutable.Specification.is(Specification.scala:12)
    at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
    at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
    at org.specs2.specification.SpecificationStructure$class.map(BaseSpecification.scala:44)
    at org.specs2.mutable.Specification.map(Specification.scala:12)
    at org.specs2.specification.SpecificationStructure$class.content(BaseSpecification.scala:56)
    at org.specs2.mutable.Specification.content$lzycompute(Specification.scala:12)
    at org.specs2.mutable.Specification.content(Specification.scala:12)
    at org.specs2.runner.ClassRunner$$anonfun$apply$1$$anonfun$apply$2.apply(ClassRunner.scala:54)
    at org.specs2.runner.ClassRunner$$anonfun$apply$1$$anonfun$apply$2.apply(ClassRunner.scala:54)
    at org.specs2.control.Exceptions$class.tryo(Exceptions.scala:32)
    at org.specs2.control.Exceptions$.tryo(Exceptions.scala:109)
    at org.specs2.runner.ClassRunner$$anonfun$apply$1.apply(ClassRunner.scala:54)
    at org.specs2.runner.ClassRunner$$anonfun$apply$1.apply(ClassRunner.scala:53)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
    at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
    at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
    at org.specs2.runner.ClassRunner.apply(ClassRunner.scala:53)
    at org.specs2.runner.ClassRunner.start(ClassRunner.scala:31)
    at org.specs2.runner.ClassRunner.main(ClassRunner.scala:24)
    at org.specs2.runner.NotifierRunner.main(NotifierRunner.scala:24)
    ... 6 more

Process finished with exit code 1
下面是一段在sbt中运行但在Intellij中失败的代码:

class ReportsDemographicsComponentTest extends Specification with ReportsComponents {

  "ReportsDemographicsComponent" should {

    s"return empty list of $DeviceStatistics for an inexistent deliveryId" in DBUnitTestsUtils(2) {
      accountId => implicit session =>

        val service = new ReportsDemographicsService(accountId)
        val res = service.deviceStatistics(-1)

        res.size mustEqual 0
    }
}

我尝试重新启动Intellij,
sbt
,清理项目,但没有成功。从
sbt
命令行运行测试时,一切正常。

在我的情况下,关闭Idea并通过发出

sbt gen-idea
注意: 您必须将此行放入
project/plugins.sbt
中才能使用以下命令:

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

您是如何将项目加载到intellij中的?intellij sbt支持或sbt intellij项目生成器插件。向我们展示您的测试代码;这似乎就是我怀疑您使用的specs2版本太旧的地方。你的版本是什么?是specs2 2.3.10。我知道这不是最新版本,但我和其他使用相同版本的人一起工作,在运行他们的测试时没有问题。你确定你的Intellij项目中有相同的specs2版本吗?有时,当您更新sbt构建时,Intellij项目不会得到更新。在我看来,sbt文件和Intellij项目之间的jar不匹配。