Archive for the 'hudson' Category

Fully automated Web Application Testing with Selenium and Hudson

Lately i have been setting up a fully autometd Web Application Test environment. I just wanted to share my experiences!

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:
  1. Start the Selenium-RC server from Hudson
  2. Compile the application and the test cases
  3. Reinitialization of the database via DBUnit
  4. Starting the Tomcat - application server
  5. Running the Selenium test cases
  6. 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):
DISPLAY=:0 java -jar ${WORKSPACE}/ecm.server/lib/test/selenium/selenium-server.jar -log ${WORKSPACE}/ecm.server/selenium.log &



Compile the application of the test cases by Ant +

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.

   

Starting the Tomcat - application server from Hudson

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:


As you can see at first i delete the old test results. After that the tests are run via the testng ant task using ReportNG to generate some nice looking test results.


Publish the test results in Hudson

After the tests are run i use two hudson Post-build Actions to publish the test results.




The first is Archive the artifacts:
This Actions archives all resources of the specified folder from the last build. Thiese are the generated TestResults which provide some nice looking results.

In order to get statistics of all test cases ever run i also use the Action Publish JUnit test result report, which uses the Junit xml Resultfiles and generates statisics.

The result can be seen in the hudson project page. There you see an overview of the test statisics.



By clicking on the archived "index.html" you can display the reportng testresult:


Cheers