Wednesday, April 16, 2014

Spock - BDD

@Grapes([
  @Grab(group='org.spockframework', module='spock-core', version='0.7-groovy-2.0')
])
import spock.lang.*

// see: http://meetspock.appspot.com/
// https://github.com/spockframework/spock

class MyFirstSpec extends Specification {
  def "test min"() {
    given: "min of a&b"

    expect:
    Math.min(a, b) == c

    where:
    a << [1,2]
    b << [4,3]
    c << [1,2]
  }
  
  def "test string length"() {
    given: "length of name"

    expect:
    name.size() == length

    where:
    name << ["Sally","Bill"]
    length << [5,4]
  }
}