12.3 Functional Testing 2.3.8

See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 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/webtest `G-Func` - http://grails.org/plugin/functional-test `Geb` - http://grails.org/plugin/geb `Selenium-RC` - http://grails.org/plugin/selenium-rc `WebDriver` - http://grails.org/plugin/webdriver Consult the documentation for each plugin for its capabilities. #### 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 set ##### war 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
Note that the same build/config options for the run-war command apply to functional testing against the 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
Note that this does not change the test base url to be https, it will still be http unless the `-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
This option is ignored if the `-baseUrl` option is specified. ##### baseUrl The `baseUrl` option allows the base url for tests to be specified.
    grails test-app functional: -baseUrl=http://mycompany.com/grailsapp
This option will prevent the local grails application being started unless `-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. | Quick Reference (hide)