Fully automated Web Application Testing with Selenium and Hudson
My application has a number of selenium tests that i wanted to run on our continious integration server (hudson). My current scenario includes the following steps:
- Start the Selenium-RC server from Hudson
- Compile the application and the test cases
- Reinitialization of the database via DBUnit
- Starting the Tomcat - application server
- Running the Selenium test cases
- Publish the test results in Hudson
Start the Selenium-RC server on Hudson
The Selenium RC server is started from Hudson at the beginning of each build as a shell call.
As you can see in the picture this step is done before i trigger an ant script which includes all the following steps. Therefore it is imperative that a user is logged on to the DISPLAY =: 0.
The full command is here (As you can see, i also specified the path to a logfile):
The first step that is triggered from the ant script is a full build of the webapplication and the selenium test cases.
Reinitialization of the database from Ant via DBUnit
The next step is a full reset of the database used by the application with a initial set of data. Using DBUnit this can be done very easy. I just made an export from an initial dataset which is written to the database every build. Here you can see the ant target which does the job.
I also setup a dedicated tomcat on the build machine used for the selenium testcases. It is started from the Ant script in the next step. You can see the ant script here, note that ant is waiting until tomcat is started up by checking if the webport of tomcat is online.
Running the Selenium test cases from Hudson, by Ant
the Selenium tests are also run from Antwith the following ant script:
Publish the test results in Hudson
After the tests are run i use two hudson Post-build Actions to publish the test results.








