Exceptions thrown in steps get swallow in the IDEA runner (not SBT)

23 views
Skip to first unread message

Toby Weston

unread,
Jun 18, 2015, 7:12:31 AM6/18/15
to specs2...@googlegroups.com
Hello,

If we have the following self-contained immutable Specification, an exception is thrown in the setup (a step) but when run in IntelliJ IDEA, it wont get reported and our test continues.

Any ideas how we can either get stopOnFail working for steps or any other mechanism for handling exception on setup?

Thanks

import org.specs2.Specification
import org.specs2.specification.dsl.GWT
import org.specs2.specification.script.StandardDelimitedStepParsers

class StepExceptionsDontFailTest extends Specification with GWT with StandardDelimitedStepParsers {

  def is = {
    stopOnFail ^ s2"""
        Do exceptions get logged          $throwException
        or will my test make assertions?  $assert
      """
  }

  def throwException = step {
    throw new IllegalArgumentException("Hello you!")
    "Bob"
  }

  def assert = {
    true must_== true
  }

}

etorreborre

unread,
Jun 18, 2015, 9:39:07 AM6/18/15
to specs2...@googlegroups.com, toby....@gmail.com
Hi Toby,

The Intellij issue looks like an incomplete implementation of the NotifierPrinter that is used to report results for IDEA. I'll fix this tomorrow.

Then what you want for your step is to use .stopOnError on it because "stopOnFail" as an argument is only supposed to fail if there are failures before a step:

  def throwException = step {
    throw new IllegalArgumentException("Hello you!")
    "Bob"
  }.stopOnError

Eric.

Toby Weston

unread,
Jun 22, 2015, 3:30:49 AM6/22/15
to specs2...@googlegroups.com, toby....@gmail.com
Great stuff. Thanks very much.
Reply all
Reply to author
Forward
0 new messages