Integration and Testing
Plugins for integrating with testing frameworks, running integration tests, and managing test resources.
About
The Integration and Testing category covers Maven plugins that help in:
Running unit tests and integration tests
Managing test resources and environments
Integrating with testing frameworks (e.g., JUnit, TestNG, Cucumber)
Generating test execution reports
Ensuring phased test execution (unit tests vs integration tests)
Supporting end-to-end test automation in CI/CD pipelines
These plugins ensure our application is thoroughly tested at various levels before packaging or deployment.
Need for Integration and Testing Plugins
Automatically run tests during Maven phases (
test
,verify
)Control test scope (unit vs integration)
Generate detailed reports of test outcomes
Manage test dependencies and resources
Integrate with external tools like Cucumber, Arquillian, Selenium, or Dockerized test setups
maven-surefire-plugin
Handles execution of unit tests (typically fast, in-memory tests). Bound to the test
phase of the lifecycle.
Syntax
Key Configurations
includes
, excludes
Control which test classes to include or exclude
test
Run specific test class
forkCount
, reuseForks
Parallel and fork control
systemPropertyVariables
Set system properties
Usage
Automatically picks up
Test*.java
or*Test.java
.
maven-failsafe-plugin
Used for integration tests, designed to run after the application has been built. Bound to the integration-test
and verify
phases.
Syntax
File Naming Convention
Failsafe runs tests named like:
*IT.java
(IT = Integration Test)*ITCase.java
Command
maven-resources-plugin
Copies and filters test-specific resources (like config files, test data) to target/test-classes
.
Syntax
Use Cases
Load
.properties
,.yml
, or.json
for testsFilter placeholders using Maven properties
cucumber-maven-plugin
Syntax Example
Requires Cucumber JUnit/TestNG runner and feature files in
src/test/resources
.
docker-maven-plugin / fabric8-maven-plugin
Used to spin up Docker containers (e.g., DB, Redis, MQ) during integration tests.
Use Cases
Test services against real DBs (e.g., PostgreSQL) using Docker
Spin up microservices before integration tests
These are not part of Maven core but useful in microservice or system integration testing.
Last updated
Was this helpful?