This is an example Geb-Spock-Groovy implementation of Acceptance Test Driven Development (ATDD). However, it also provides an extensible framework that can be reused by replacing the existing tests.
These tests show how to use Geb-Spock to verify...
- that critical elements are on a page
- the ability to login as a user
It also demonstrates the basic features of the Geb-Spock framework and how they can be extended.
This project can be run...
- Fully locally running the tests against a local browser
- Locally running the tests against a containerized browser
- Fully in 2 separate Docker containers, one containing the tests the other the browser
This framework contains support for...
- Local thru fully containerized execution
- Using Selenium Standalone containers eliminating the need for locally installed browsers or drivers
- Multiple local browsers with automatic driver management
- Tagging system (including and excluding)
- Groovy metaprogramming
The tests in this project can be run be run fully in Docker assuming that Docker is installed and running. This will build a docker image of this project and execute the tests against a Selenium Standalone container.
You must have docker installed and running on your local machine.
- Ensure Docker is running
- Run the
project docker-compose.yml
file (this runs using the Chrome standalone container)
docker-compose up
This is a single module maven project which will execute the automated tests.
To run the automated tests, execute...
mvn clean test
command-line-arguments
- To run using the "built in" htmlunit subset of tests, execute...
mvn clean test -Dgeb.env=htmlunit
The easiest way to run these tests locally is to use Docker and the Selenium Browser Containers.
- Start Docker
mvn clean test -Dgeb.env=dockerChrome
ormvn clean test -Dgeb.env=dockerFirefox
- Connect to vnc://localhost:5900 (On Mac you can simply enter this address into a Browser)
- When prompted for the (default) password, enter
secret
-Dgeb.env=
...
Example:
-Dgeb.env=chrome
Currently the following browsers are supported in this project:
htmlunit
- built-indockerChrome
- managed Selenium Chrome ContainerdockerFirefox
- managed Selenium Firefox Containerchrome
- Google Chrome (requires Chrome)chromeHeadless
- Google Chrome run in headless mode (requires Chrome > 59)firefox
- Mozilla Firefox (requires Firefox)firefoxHeadless
- Mozilla Firefox run in headless mode (requires Firefox > 56)phantomjs
- PhantomJS headless browsersafari
- Apple Safari (requires Safari)
-Dspock.run.target=
...
Example:
-Dspock.run.target=qa
-Dspock.run.includes=
...
Example:
-Dspock.run.includes=allexcludedfromhtmlunit,ondemand
-Dspock.run.excludes=
...
Example:
-Dspock.run.excludes=javascript
Dspock.run.excludes.context=ignore
- By default, tests will use the headless HtmlUnit browser
To run with specific browser drivers, look in the GebConfig.groovy file for any configured environments and pass the value to your maven command using the 'geb.env' command line argument.
Example:
mvn clean test -Dgeb.env=chrome
- Maven 3.x
- JDK 1.8