Integration tests

JUnit and Integration tests

Integration tests are run using the maven failsafe plugin. For detailed information see the Maven failsafe documentation.

Short version:

  • any JUnit class Test* or *Test will be run by the test target
  • any JUnit class IT* or *IT will be run by the verify target (run after the test target)

Usually the following are unit tests:

  • any test that mocks almost all dependencies
  • any test that does not depend on any database (hsqldb included)

The following should be considered integration tests:

  • any test that boots an AcrossContext that contains the module under test or the modules it depends on

POM configuration

The failsafe plugin needs to be configured in the pom.xml.  For simplicity sake (buildserver and Sonar integration), the failsafe reports are put in the same folder as the surefire (unit tests) reports.

POM extension for failsafe plugin

Running only the integration tests

When you execute mvn verify then first the unit tests will be executed, followed by the integration tests.  You can run only the integration tests by running mvn failsafe:integration-test.  If you start from a clean checkout, you need to compile them as well: use mvn compile test-compile failsafe:integration-test.

Writing tests

If a module extends the database schema, it should preferably have one or more integration tests that perform the module installation and can easily be re-run against different datasources.

Integration tests can easily be written using the Across test library, see /wiki/spaces/AX/pages/12648455.

Buildserver datasources

The buildserver is provided with a default containing the following datasources:

mysqlMySQL 5 (linux)
oracleOracle 11G (Windows)
mssqlSQL Server 2008

See /wiki/spaces/AX/pages/12648483 for naming conventions and sql scripts