grails/grails-functional-tests-v2

Name: grails-functional-tests-v2

Owner: grails

Description: null

Created: 2012-01-18 14:29:15.0

Updated: 2013-10-11 08:27:27.0

Pushed: 2013-04-10 18:45:47.0

Homepage:

Size: 587

Language: Groovy

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Grails Functional Test Suite v2

New version of the functional test suite for Grails based on Gradle, Spock and Geb.

Tests are found within the src/test/groovy directory.

A basic test looks like:

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"
    }
}

The above example creates a new project and tests it, deleting it on completion. To test an existing project you can instead use BaseApplicationSpec:

class RunAppSpec extends BaseApplicationSpec {
    String getApplication() { "foo" }
    void "Test run-app starts correctly"() {
        when:"The home page is requested"
            go ""
        then:"The Grails welcome page is shown"
            title == "Welcome to Grails"            
    }
}

The application needs to be created in the “apps” directory of the project before this test can be run.

Tests are executed using standard Gradle test command:

./gradlew test

Running a single test can be done with:

./gradlew -Dtest.single=RunApp test

Where “RunApp” above is the test name.

By default the test suite tries to look for GRAILS_HOME in the directories ../grails-core or ../grails-master. If you prefer to tell the suite where Grails is you can do:

./gradlew -Dgrails.home=/path/to/grails test

Tests can also be run from the IDE. Just generate Eclipse or Intellij project files:

./gradlew eclipse
./gradlew idea

Import the project into your IDE and run the specs directly.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.