Navigation: ()

Integration Testing

See Also: DevSetup, MavenInfo, #63 (integration testing), Integration strategies with maven2, Better Builds With Maven Book - section 4.13 (Testing J2EE Application)

Types of tests and where they go

We are concerned with two types of tests:

  • unit-tests - Those that don't require any kind of infrastructure to be run
  • integration-tests - Those that assume some infrastructure is running

Location:

  • unit-tests - src/test/{java,resources,groovy,...}
  • integration-tests - src/it/{java,resources,groovy,...}

Integration tests can also be added to the src/it directory of the integrationtests sub-module.

Note that Maven2 is a bit immature and we've had to do a bit of work to make integration testing work. There is discussion within the Maven community of using src/it or possibly src/test/{unit,it,...}. Time will tell.

Running integration tests

There are two ways to run tests.

  • The first is to run them for just one module. This is useful when you are a developer working on a specific module.
  • The other is to run all the integration tests at once. This is used by continuum to ensure nothing has broken.

Per-module execution

This is meant for the developer as it is quicker and only runs the tests you've written for your module. You can either start ecqs and fedora and keep them running: mvn ant-tasks:ecqs-start ant-tasks:fedora-start.

Or you can run the tests with the it-startenv profile that will start (and usualy stop) ecqs and fedora when running your tests.

To run your integration tests, do the following:

  cd <my-module>
  mvn clean install
  mvn -Pit-helper verify

(If you want to start/stop ecqs/fedora, the command is: mvn -Pit-helper,it-startenv verify.

NB: Using the it-helper profile will disable normal unit-tests. Don't assume you can just do mvn -Pit-helper clean install.

NB: The it-helper profile does not do well with sub-modules. If you want to run integration tests of multiple modules, do it with the integrationtests sub-module.

Project-wide integration tests

The integrationtests sub-module collects all the integration tests from its peer modules and their sub-modules by looking for everything in **/src/it/. It compiles all those tests and runs them.

It is usually run with the it-startenv profile that starts and stops ecqs and fedora before and after test runs.

To run the integration tests, do the following:

  cd .../integrationtests
  mvn -Pit-startenv clean verify ant-tasks:ecqs-stop ant-tasks:fedora-stop

Note: The ant-tasks:ecqs-stop and ant-tasks:fedora-stop are necessary because if any of the tests fail, maven will not run the post-integration-test phase (which is where ecqs and fedora are stopped by it-startenv).

Continuum Notes

Continuum runs ant-tasks:build-and-test ant-tasks:fedora-stop ant-tasks:ecqs-stop.

ant-tasks:build-and-test does the following (see [315]):

  • Remove the install directory so that DBs are cleaned out
  • mvn clean install
  • cd head/topazproject/integrationtests; mvn clean verify

Note: It is necessary to get continuum to run "clean install" once before having it run the command above or the ant-tasks plugin will not be installed and continuum will fail.