danielvdende
danielvdende

Reputation: 710

ScalaTest in Intellij Idea halts after failed test

I'm writing ScalaTest code in Intellij Idea 14, and I would like to see the output in Intellij. I currently have 2 tests, of which I expect one to fail, the other to succeed. When I run the tests in Intellij, as soon as the failing one is executed, a massive stack trace appears in the test output log, and the other test is not executed at all, which is really annoying. If I navigate to the project directory and execute sbt test the test run proceeds normally (i.e. the failed test is marked as failure, the succeeding tests is marked as succeeding).

Is there some ScalaTest configuration specific for Intellij that needs to be set other than the installation of the Scala plugin?

The stack trace that appears in Intellij is as follows:

"[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)

As per request, a screenshot: enter image description here

Upvotes: 0

Views: 708

Answers (2)

Bill Venners
Bill Venners

Reputation: 3659

Actually IntelliJ is running the other test but just not showing the output. The default in IntelliJ is to just show tests that fail, and to hide ones that succeed. There's a button (in the window where they show the red icon for the failed test) that you can click to see all tests, both passing tests and failing tests.

Upvotes: 2

Suma
Suma

Reputation: 34393

What you want should be the default behaviour, and it is also what I see when my ScalaTest tests are failing - some failing does not prevent the other to run.

See my test console with one failing test:

enter image description here

In which IDE window do you see the failed test stack?

Perhaps you could try updating to at least IDEA 15 (there is also IDEA 16 EAP, but you may perhaps not like running pre-release software)? It might be difficult to get proper support for IDEA 14.

Upvotes: 0

Related Questions