O'Reilly logo

Scala Test-Driven Development by Gaurav Sood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required