Thursday, February 18, 2010

Setting up Selenium 2.0 test engine with Hudson and Maven

In our project we as a team wanted to implement a strict ATDD practice where we write functional test cases for features before implementing them. We also wanted to write some of these tests as automated browser based tests and decided to use Selenium 2.0 (currently in alpha).

Our Continuous Integration server is Hudson but it is running in Linux so it cannot run the Internet Explorer driver. So we decided to set up another instance of Hudson running in a Windows box to run the tests with IE, Firefox and Chrome. After a very easy Hudson installation (Java WebStart + setting it to run as a windows service from the Hudson web gui with one click!), lengthy maven configuration and exploiting one windows vulnerability we now have a setup that runs the tests in three browsers and publishes the results to our main Hudson CI server.

Here is a short summary of the Hudson + maven setup we have:
  • Hudson has separate jobs for each browser. The webdriver class name is passed in MAVEN_OPTS using -D to our custom test runner class that runs the functional tests with the specified driver.
  • Maven has a separate profile called functional-test used to run the tests.
  • Functional tests are run in the integration-test-phase. Integration tests are not ran in functional test profile.
  • Jetty-plugin is started in the pre-integration-test phase of the maven build to run our application.
  • Hudson runs jobs one at a time because we have not yet (Note to self: //TODO) configured different Jetty ports for different jobs.
  • Maven arguments to run the individual jobs and to build the correct reports and to fail if tests fail (not default in failsafe...): "-P functional-test clean integration-test surefire-report:report failsafe:verify".
Below some relevant excerpts from our pom.xml.

First the profile for functional tests. We have naming convention for them "*FunctionalTest". It does not overlap our unit tests because they are named in BDD convention "*Spec" (we use JDave instead of JUnit). Integration tests are named "*IntegrationTest".



Integration test plugin failsafe config in build-section of the pom:

No comments:

Post a Comment