concept Spock in category software development

appears as: Spock
Agile ALM: Lightweight tools and Agile strategies

This is an excerpt from Manning's book Agile ALM: Lightweight tools and Agile strategies.

DSLs help create tools that solve problems in a specific domain. Spock and easyb are two BDD testing tools implemented as DSLs in Groovy.

Spock (http://code.google.com/p/spock/) is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language. As you can see from the following snippet, Spock code tweaks Java syntax quite a bit. It allows you to create several sections describing different aspects of your test, each labeled accordingly, such as expect:, where:, when:, and then:.

class HelloSpock extends spock.lang.Specification {
    def "can you figure out what I'm up to?"() {
        expect:
        name.size() == size

        where:
        name << ["Kirk", "Spock", "Scotty"]
        size << [4, 5, 6]
    }
}

Whereas easyb takes a more traditional approach to defining DSLs in Groovy, Spock relies on compile-time AST Transformations and therefore can stretch the allowed syntax a bit further. While Spock provides syntax that looks different from typical Java or Groovy code, Spock feels comfortable to developers, who are used to unit testing frameworks like JUnit. By leveraging the power of Groovy meta-programming and DSL definition abilities, together with being able to help pure Java shops, both frameworks serve as good examples of typical citizens of the Groovy ecosystem.