12.3 Functional Testing - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 2.3.8
12.3 Functional Testing
Functional tests involve making HTTP requests against the running application and verifying the resultant behaviour. The functional testing phase differs from the integration phase in that the Grails application is now listening and responding to actual HTTP requests. This is useful for end-to-end testing scenarios, such as making REST calls against a JSON API.Grails does not ship with any support for writing functional tests directly, but there are several plugins available for this.Canoo Webtest
- http://grails.org/plugin/webtestG-Func
- http://grails.org/plugin/functional-testGeb
- http://grails.org/plugin/gebSelenium-RC
- http://grails.org/plugin/selenium-rcWebDriver
- http://grails.org/plugin/webdriver
Common Options
There are options that are common to all plugins that control how the Grails application is launched, if at all.inline
The-inline
option specifies that the grails application should be started inline (i.e. like run-app
).This option is implicitly set unless the baseUrl
or war
options are setwar
The-war
option specifies that the grails application should be packaged as a war and started. This is useful as it tests your application in a production-like state, but it has a longer startup time than the -inline
option. It also runs the war in a forked JVM, meaning that you cannot access any internal application objects.grails test-app functional: -war
https
The-https
option results in the application being able to receive https requests as well as http requests. It is compatible with both the -inline
and -war
options.grails test-app functional: -https
-httpsBaseUrl
option is also given.httpsBaseUrl
The-httpsBaseUrl
causes the implicit base url to be used for tests to be a https url.grails test-app functional: -httpsBaseUrl
-baseUrl
option is specified.baseUrl
ThebaseUrl
option allows the base url for tests to be specified.grails test-app functional: -baseUrl=http://mycompany.com/grailsapp
-inline
or -war
are given as well. To use a custom base url but still test against the local Grails application you must specify one of either the -inline
or -war
options.