Sunday, September 16, 2007

Continous web testing with Selenium, Maven and Continuum part 2

Update: Fixed camelCase in localRepository tag.

It's been a busy week, with JavaZone and some exiting things going on in my project at the same time.

I'll get straight to the point and post an exampe app that will solve the problems from the previous post.

I started off with a maven archetype create webapp.

I added configuration of the Jetty plugin (note that this isn't really necessary to get the rest working, but is handy for testing out the webapp with mvn jetty:run).

I put the web-test running in its own profile, so it won't be ran with each mvn install. This is to underline the fact that you probably don't want the web-tests to be run each time you build the app. Web tests take too much time and should be done by your CI system.

So, all the details of configuring maven for running Selenese tests are inside the with id "web-test". I've done a few other modifications as well, adding a couple of snapshot repos, and the web tests of course. I added a simple little test that verifies that it can find the text "Hello World!" when browsing to localhost:8080/maven-selenium-example.



  • Firefox 2.0 or later installed
  • Maven 2.0.7 (or thereabouts) installed
  • M2_REPO (environment variable) pointed to a folder without spaces *
* Because of this bug, the path to your maven repo can not contain spaces (as in C:\Documents and Settings\Thomas.Nicolaisen\.m2\repository). So, move your repository to f.ex. c:\m2-repo and change C:\Documents and Settings\[usernemame]\.m2\settings.xml to include:


This will most likely not be necessary on a non-windows system.

  1. Unzip
  2. Commando-line into \maven-selenium-example
  3. Type mvn install -Pweb-test
  4. Wait a while for all the dependencies to download
  5. Build successful!
That last maven parameter instructs maven to use the web-test profile.

Be aware that since there are plenty of snapshot dependencies in this configuration, any of them could be upgraded any day and (if the developers have done a poor job) break the web-test configuration. If you want a 100% stable integration test environment you should specify version number on each plugin (especially cargo-maven2-plugin, and change the selenium-maven-plugin to non-snapshot).