https://github.com/grails/grails-functional-tests-v2
https://github.com/grails/grails-functional-tests-v2
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/grails/grails-functional-tests-v2
- Owner: grails
- Archived: true
- Created: 2012-01-18T14:29:15.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2013-04-10T18:45:47.000Z (about 13 years ago)
- Last Synced: 2025-04-20T15:23:00.979Z (about 1 year ago)
- Language: Groovy
- Homepage:
- Size: 573 KB
- Stars: 8
- Watchers: 7
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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.