Book Image

Groovy for Domain-Specific Languages, Second Edition

By : Fergal Dearle
Book Image

Groovy for Domain-Specific Languages, Second Edition

By: Fergal Dearle

Overview of this book

Table of Contents (20 chapters)
Groovy for Domain-specific Languages Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Introduction to DSLs and Groovy
Index

Spock tests


The Spock Framework is a behavior-driven development (BDD) tool built on top of JUnit. Spock uses the features of the Groovy language to add BDD style syntax to JUnit tests. Spock allows us to write our test specifications as "given, when, then" style expressions, but under the covers, they still run as JUnit tests and can still be run by the JUnit runner. This means that Spock tests are compatible with most build tools, IDEs, and continuous integration servers.

Given, when, then

The main characteristic of BDD is the concept of expressing tests in plain English sentences. User stories should be accompanied with clear descriptive acceptance criteria, which describe expected behavior in the system under test.

In support of this concept, an accepted dialect has evolved to describe acceptance tests. The general form follows the pattern: given (some initial context), when (some event or stimulus occurs), then (a certain outcome is expected).

A simpler version when no stimulus is involved...