我在Intellij Idea 14中编写ScalaTest代码,我希望看到Intellij中的输出。我目前有2个测试,其中我希望一个失败,另一个成功。当我在Intellij中运行测试时,一旦执行了失败的测试,测试输出日志中就会出现大量的堆栈跟踪,而其他测试根本不会执行,这真的很烦人。如果我导航到项目目录并执行sbt test
,则测试运行正常进行(即失败的测试被标记为失败,后续测试被标记为成功)。
是否有一些特定于Intellij的ScalaTest配置需要设置,而不是安装Scala插件?
Intellij中显示的堆栈跟踪如下:
"[MOckito testing]" did not equal "[expected result]"
ScalaTestFailureLocation: ComapiSpec$$anonfun$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2 at (ComapiSpec.scala:26)
org.scalatest.exceptions.TestFailedException: "[MOckito testing]" did not equal "[expected result]"
at org.scalatest.MatchersHelper$.newTestFailedException(MatchersHelper.scala:160)
at org.scalatest.Matchers$AnyShouldWrapper.shouldEqual(Matchers.scala:6326)
at ComapiSpec$$anonfun$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply$mcV$sp(ComapiSpec.scala:26)
at ComapiSpec$$anonfun$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply(ComapiSpec.scala:26)
at ComapiSpec$$anonfun$1$$anonfun$apply$mcV$sp$1$$anonfun$apply$mcV$sp$2.apply(ComapiSpec.scala:26)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at akka.http.scaladsl.testkit.RouteTest$$anonfun$check$1.apply(RouteTest.scala:53)
at akka.http.scaladsl.testkit.RouteTest$$anonfun$check$1.apply(RouteTest.scala:53)
at akka.http.scaladsl.testkit.RouteTestResultComponent$RouteTestResult.$tilde$greater(RouteTestResultComponent.scala:52)
at ComapiSpec$$anonfun$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ComapiSpec.scala:25)
at ComapiSpec$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ComapiSpec.scala:25)
at ComapiSpec$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ComapiSpec.scala:25)
at org.scalatest.Transformer$$anonfun$apply$1.apply$mcV$sp(Transformer.scala:22)
at org.scalatest.OutcomeOf$class.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.Transformer.apply(Transformer.scala:22)
at org.scalatest.Transformer.apply(Transformer.scala:20)
at org.scalatest.WordSpecLike$$anon$1.apply(WordSpecLike.scala:953)
at org.scalatest.Suite$class.withFixture(Suite.scala:1122)
at org.scalatest.WordSpec.withFixture(WordSpec.scala:1881)
at org.scalatest.WordSpecLike$class.invokeWithFixture$1(WordSpecLike.scala:950)
at org.scalatest.WordSpecLike$$anonfun$runTest$1.apply(WordSpecLike.scala:962)
at org.scalatest.WordSpecLike$$anonfun$runTest$1.apply(WordSpecLike.scala:962)
at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
at org.scalatest.WordSpecLike$class.runTest(WordSpecLike.scala:962)
at org.scalatest.WordSpec.runTest(WordSpec.scala:1881)
at org.scalatest.WordSpecLike$$anonfun$runTests$1.apply(WordSpecLike.scala:1021)
at org.scalatest.WordSpecLike$$anonfun$runTests$1.apply(WordSpecLike.scala:1021)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:413)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:390)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:427)
at org.scalatest.SuperEngine$$anonfun$traverseSubNodes$1$1.apply(Engine.scala:401)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:401)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:396)
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:483)
at org.scalatest.WordSpecLike$class.runTests(WordSpecLike.scala:1021)
at org.scalatest.WordSpec.runTests(WordSpec.scala:1881)
at org.scalatest.Suite$class.run(Suite.scala:1424)
at org.scalatest.WordSpec.org$scalatest$WordSpecLike$$super$run(WordSpec.scala:1881)
at org.scalatest.WordSpecLike$$anonfun$run$1.apply(WordSpecLike.scala:1067)
at org.scalatest.WordSpecLike$$anonfun$run$1.apply(WordSpecLike.scala:1067)
at org.scalatest.SuperEngine.runImpl(Engine.scala:545)
at org.scalatest.WordSpecLike$class.run(WordSpecLike.scala:1067)
at ComapiSpec.org$scalatest$BeforeAndAfterAll$$super$run(ComapiSpec.scala:17)
at org.scalatest.BeforeAndAfterAll$class.liftedTree1$1(BeforeAndAfterAll.scala:257)
at org.scalatest.BeforeAndAfterAll$class.run(BeforeAndAfterAll.scala:256)
at ComapiSpec.run(ComapiSpec.scala:17)
at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:55)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2563)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:2557)
at scala.collection.immutable.List.foreach(List.scala:381)
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:2557)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1044)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1043)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2722)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1043)
at org.scalatest.tools.Runner$.run(Runner.scala:883)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:138)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
答案 0 :(得分:2)
实际上IntelliJ正在运行另一个测试,但只是没有显示输出。 IntelliJ中的默认设置是仅显示失败的测试,并隐藏成功的测试。有一个按钮(在窗口中,它们显示失败测试的红色图标),您可以单击以查看所有测试,包括通过测试和未通过测试。
答案 1 :(得分:0)
你想要的应该是默认行为,它也是我在ScalaTest测试失败时看到的 - 一些失败并不会阻止另一个运行。
通过一个失败的测试来查看我的测试控制台:
您在哪个IDE窗口中看到失败的测试堆栈?
也许您可以尝试updating to at least IDEA 15(还有IDEA 16 EAP,但您可能不喜欢运行预发布软件)?可能很难为IDEA 14获得适当的支持。