Acceptance specification is distinguished from unit specification by separating the test code from the expectation definition. Let's look at another example of how to use acceptance specification in Specs2:
package com.packt import org.specs2.Specification class ExampleAcceptanceSpec extends Specification { def is = "Our example specification" ^ "and we should run t1 here" ! t1 ^ "and we should run t2 here" ! t2 def t1 = success def t2 = pending }
The thing not to be missed here is the specification that is imported. Unlike the unit specification, we are importing org.spec2.Specification
here instead of org.spec2.mutable.Specification
.
In this example, the is
method is the one that bootstraps the entire test. A fragment, which contains all the examples, is returned in this method.
The technique gives back a Fragments
object containing every one of the cases...