Acceptance specification

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, ...

Get Scala Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.