Throwing an exception in the cleanup: block hides exception in then: block

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Throwing an exception in the cleanup: block hides exception in then: block

Kostis Kapelonis
Hello all

Quick question

// Hit 'Run Script' below
class MyFirstSpec extends Specification {
  def "let's try this!"() {
    when:
    int b =2

    then:
    throw new IllegalArgumentException()

    cleanup:
    throw new NullPointerException()
  }
}

What would be the expected result of this Spec? What exception should
be printed first?

At the moment the NPE is reported only (i.e. the cleanup: block is
honoured first)

But I am thinking that maybe the then: block is more important?

Any thoughts? Is this by design?

Kostis

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.