Tests

Unit and Integration Tests

Maven divides tests into two phases, one for unit tests and another for integration ones. Running the integration tests will run both the unit and integration tests.

In a general way, unit tests are small and fast tests, where the components use fake dependencies, or no dependencies at all. While integration tests connect several components and services.

It is recommended using the default test search methods, which will run all the test clases with "Test" in the name as unit test, and those with "IT" as integration tests. They will be found by scanning the packages in the test code folder.

Commands

To run both unit and integration tests the use the following command:

mvn verify

To run only unit tests use the following command:

mvn test

Plugins

Maven uses two plugins to take care of the tests:

Some additional plugins can be used to improve testing results:

  • JaCoCo, generates coverage reports from Surefire and Failsafe.

  • Surefire Report, generates the unit tests report.

Last updated