Spock Web Console

subscribe to the feed Subscribe
alan (via #spockwebconsole)
tweet this script Tweet

alan

Published 4 months ago by Anonymous
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.*

class GetSpec extends Specification {
  def "Testing getter"() {
    setup:
    def foo = new Foo(name: "alan")

    expect: "Getter is called"
    foo.name == "Hello alan"

    and: "Call field directly"
    foo.@name == "alan"
  }
}

class Foo {
    String name
    def getName() { 
      "Hello $name" 
    }
}