Introduction

The webtest-maven-plugin allows running Canoo Webtest within a Maven 2 build but you might have guessed that already. Furthermore the plugin provides some additional syntactic sugar such as

  • run the tests in a loop
  • force a build error even when errors and failures are explictely ignored
  • check the result file for certain strings and fail if they exists

Getting some examples

The hardest part is making the first successful steps when being new to Canoo Webtest and/or Maven. For some inspiration what you can do (e.g. JavaScript execution, embedding Groovy steps, testing PDF documents) check out the integration tests under ./src/test/itX

Running tests in a loop

This is quite handy when you do load tests in parallel - in the background you run your webtests to ensure that the functional tests still work under high load. The loop exits after a number of configurable iterations or when encountering the first problem.

Force a build error

A common problem with Continous Integration is the fact that you want run all tests and not stop after the first problem. Running all tests means also to finish the build (e.g. generating test reports) before you force a build failure - this is implemented in webtest:verify-result.

Checking the result files

Another common problem are server processing errors behind a shiny HTTP 200 result code, e.g. "An application error has occured" plus two screen meter of stack trace showing off all your implementation details. So if you fail to detect this magic messages in your test you have a problem while adding those checks to all tests makes them much harder to maintain. Therefore webtest:verify-filecontent is your friend.