GRAILS.IO Avatar

Functional testing Grails core with Gradle, Spock and Geb

Today I pushed a new functional test suite for Grails that is based on Gradle, Spock and Geb.

I have been relatively frustrated with our existing functional test suite and wanted to modernize it to take advantage of all the latest innovations happening in the Groovy testing community.

The requirements fulfilled by the new test suite are as follows:

  • Allow tests to be created in a standard Gradle structure 
  • Allow tests to be run from the IDE
  • Enable easy scripting of the Grails command line
  • Enable easy web function testing of the running application

An example of what I came up with can be seen below:

 class RunAppSpec extends BaseSpec { void "Test run-app starts correctly"() { given:"A new project" grails { createApp "test" runApp() } when:"The home page is requested" go "" then:"The Grails welcome page is shown" title == "Welcome to Grails" } } 

As you can see the Grails command line can be easily scripted with the grails block. Then testing of web UIs is left to Geb’s DSL.

Hopefully this will also make it easier for folks to contribute functional tests. Please feel free to fork the repository and send us a pull request!

Replies

Likes

  1. graemerocher posted this

 

Reblogs