Maven Build

Our build system uses Apache Maven 2. All the examples below assume you are doing this from a commandline on your system. Note that the first time you run a maven build, maven will need to download a lot of software to your local repository, so allow some time for this.

  • To run all the tests at once: _ cd to the root directory of the project _ mvn clean install - cleans, sets up the database, runs the unit, integration, and acceptance tests.
    • This also sets the database up for the first time if necessary.
  • To build the test framework: _ Change directory to the testFramework/ directory _ mvn clean install
  • To build the application and run the tests: _ Change directory to the application/ directory _ mvn clean install _ If the build was successful, the war file is under the target/ directory. _ If the build failed, examine target/surefire-results/!unit/testng-results.xml for the exception traces.
  • To build and run the acceptance tests: _ Change directory to the testing/ directory _ mvn clean install - this will install tomcat, launch selenium, launch firefox, and run the acceptance tests. * If the build failed, examine target/surefire-results/testng-results.xml for the exception traces.

About the maven build

Here are some notes about the build.

  • We use Maven Build Profiles to control the build. Normally, you don't need to know anything about these - for most things a developer needs to do, there are default profiles that are used.
  • Here's a list of some of the profiles and what they are used for: _ tomcat6x - sets Maven Cargo Plugin to use tomcat 6.0 as the servlet container, and does some default configuration for Cargo and the container. _ download-container - configures Cargo to use a private servlet container. Cargo will download the container, unzip it, configure it, and start it. Note that 'download' is somewhat of a misnomer - it can also use a local zip file, and this speeds things up quite a bit. See the settings.xml section below for more info. _ firefox - configures Maven Selenium Plugin to use firefox _ ie - set Selenium to use Internet Explorer browser (we haven't tried this yet). _ dev - set Selenium or Cargo to stay attached to the console, mainly for use by developers running acceptance tests through Eclipse. _ continuous-integration - adds a jdbc.local.properties file to the Cargo container classpath, to make the application and the tests use a different database on the CI server. * insert-data - inserts initial data into the SQL database. Only done for the acceptance tests and the deploy to the test server.
  • To activate a profile, list it on the maven commandline with the -P switch: ::
    mvn clean integration-test -Pcontinuous-integration
  • Listing one profile deactivates all the default profiles, so you will need to list all the profiles that you will need to run the build: ::
    mvn integration-test -Pcontinuous-integration,download-container,tomcat6x,firefox
  • Acceptance tests: * Hardcoded ports for Selenium server and for the servlet container - right now these are hardcoded to 4444 for Selenium and 8080 for tomcat; ideally we would pass these to the tests from maven, but we haven't gotten around to this yet.
  • Continuous integration support: resource/continuous-integration/ holds resources needed for continuous integration _ integration/ and acceptance/ jdbc.local.properties files that set different databases for unit/integration tests and acceptance tests on the continuous integration server. _ writeAppInfo is a script that will write appInfo.properties. On the Hudson continuous integration server this script will use special environment variables to set the svn revsion, build id, and build tag to be visible in the application.
  • Deploy build: this directory holds resources that the continuous integration server uses to deploy a local instance of the application if the acceptance tests pass.

Integration Tests

  • Integration tests may touch a local mysql database. To make sure the database is set up correctly, run this before you run any tests: mvn pre-integration-test. _ pre-integration-test sets the test database required for integration test. _ to run individual integration test use mvn integration-test -Dtest=TheNameOfYourTestClass, this will automatically invoke pre-integration-test

Customizing

See Maven Settings Xml for information on customizing the Maven build for your environment.