Category Archives: spock

Ignore a Spock test if running in Travis CI

Thanks to Spock IgnoreIf annotation it is easy to ignore a specification running in Travis CI. Do you like to read about Grails / Geb / Groovy development? If the answer is yes, subscribe to Groovy Calamari. A weekly curated email newsletter about the Groovy ecosystem. Curated by me 🎉

How to run Grails 3 tests within IntelliJ

This post explains how to open a Grails 3 App with IntelliJ as described in the Grails 3 IntelliJ Quickcast by Jeff Scott Brown First, force IntelliJ to run Grails tests in the test environment.

Setup / Cleanup Inheritance

Craig Atkinson‘s talk at GR8Conf US Intro to Spock and Geb claimed the next about Spock Cleanup / Inheritance. Might have a hierarchy of test classes for DRY common test code Spock runs the base class setup first Then goes down the inheritance chain cleanup is the reverse, starting at test class then going up […]

How to ignore a Spock feature method in Grails 3 while running on Jenkins

It is easy to ignore a test only if the test is run in a particular environment thanks to the @IgnoreIf Spock annotation. If you run your tests in Jenkins, it is probable that the tests are being run by a user called jenkins. Thus, you can ignore a test in a Jenkins Job easily: […]

Validate a single field in a Grails 3 Domain class

Sometimes you have a domain class with multiple fields and you would like to test a single constraint. Create a Grails app test-app Add a firstName, lastName and age to the Person domain class Add the next test to validate the age constraint: Test fails: By default domain class’ fields have the constraint nullable: false. […]