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
Size: 587
Language: Groovy
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.