I have noticed that the runner does not stop when an exception is thrown by beforeAll, rather the spec is left in a potentially inconsistent state. Here is an example:
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAfterAll
class TestSpec extends Specification with BeforeAfterAll {
var value = 0
override def beforeAll(): Unit ={
if (1 == 1)
throw new Exception()
value = 1
}
override def afterAll(): Unit = {}
"value" >> {
"equals one" >> {
value must_== 1
}
}
}
After executing, I do not see the exception reported, but rather the following:
Testing started at 10:32 PM ...
'0' is not equal to '1'
Expected :1
Actual :0
<Click to see difference>
java.lang.Exception: '0' is not equal to '1'
Is this by design? I would have expected an exception in beforeAll to fail the entire spec.
I see this in both IntelliJ and SBT.