Canoo Webtest WebTest Canoo

Groovy Testing

Groovy is a scripting language that is executed as Java Byte Code. Groovy Home

This allows a Mix & Match between Groovy and Java Code.

Groovy comes with an AntBuilder that allows execution of Ant scripts from usual Groovy code. This capability allows executing WebTests, since WebTests are usual Ant tasks.

By executing WebTest from a Groovy script, you can fully leverage both the variety of WebTest steps and the sophisticated language means of Groovy for structuring your tests.

Sample use

This example fetches a page and verifies that it contains the numbers 1 through 10.

def ant = new AntBuilder()

def webtest_home ='webtest.home'

           fileset(dir:"$webtest_home/lib", includes:"**/*.jar")

def config_map = [:]
'resultpath', 'saveresponse','defaultpropertytype'].each{
    config_map[it] =['webtest.'+it]

ant.testSpec(name:'groovy: Test Groovy Scripting at creation time'){
        for (i in 1..10){
            verifyText(description:"verify number ${i} is on pages", text:"${i}")

Like in ANT, there is a two-phase approach for TaskContainers like 'testSpec'.

steps are constructed and stored (creation time)
steps are executed (runtime)

Start with groovy -Dwebtest.home=your_webtest_home test.groovy

More examples

Please find more examples of how to use Canoo WebTest through Groovy under Grails.


Latest build: development
Posted: 19-Jul-2016 17:36

WebTest 3.0 released, featuring upgrades to Java 5, Groovy 1.6, and HtmlUnit 2.4.
The release includes support for maven integration, IDE-integration like for unit tests, capturing of background JavaScript errors, new steps for mouseOver and mouseOut events, better parallel execution of tests and - as usual - lots of handling improvements.
Posted: 5 March 2009

WebTest @ JavaOne
Dierk König presented "Functional testing of web applications: scaling with Java" on Wed May 7, 13:30 at JavaOne 2008 in the Tools and Scripting Languages track.
Posted: 8 May 2008

New WebTest screencast available:
Data Driven WebTest
Posted: 13 November 2007

First WebTest screencast available:
Creating a first Webtest Project

Extend WebTest with Groovy! Groovy in Action is available in every good bookstore.
Groovy in Action
Posted: 29 January 2007