Java Reference
In-Depth Information
Thelistingdemonstratesthreedifferenttypesoftests.ThefirstshowsasimpleGETrequest
GET request, and the last does the same with a POST request. The detailed syntax comes
from the library documentation.
5
HTTPBuilder includes a class called
RESTClient
, which is used extensively in the discussion of REST in
With this infrastructure in place, both unit and integration tests can be added to a standard
project tree, and both can be executed with an embedded Jetty server using a plugin in the
Gradle build.
Gradle Integration Tests
Using Gradle's
web
and
jetty
plugins with an integration source tree, web applications
can be tested in “live” mode during a normal build.
The Geb web testing framework
Geb (
www.gebish.org
) (pronounced “jeb,” with a soft
g
) is a Groovy testing tool based on
Spock that allows tests to be written using a page-centric approach to web applications.
Website interactions can be scripted in terms of page objects, rather than simple screen
scraping. It uses a jQuery-like syntax along with Groovy semantics to do browser automa-
tion, using the WebDriver library under the hood.
The Geb project shows a lot of promise and has a growing number of adherents. It's cer-
tainly worth considering as a functional testing tool, along with alternatives like Canoo
library. An entire chapter could be written covering those tools alone, but this topic is argu-
ably already long enough.
6
By the way, do you know why it's called Selenium? When it was developed, there was a much-loathed product
called Mercury Test Runner. As it happens, the element Selenium (Se) is the cure for Mercury (Hg) poisoning.
Because this an active area of development, I recommend the testing presentations at Slide
Share by Paul King (for example,
www.slideshare.net/paulk_asert/make-tests-groovy
), one