Maven Integration Tests

Unit tests shouldn’t take long to complete and by definition should test a unit in isolation. Therefore unit tests shouldn’t include database or web framework resources.

Integration Testing is responsible putting everything together and check whether things work as expected. Maven has a special phase in its lifecycle called integration-tests that accommodates and executes integration related tests by calling mvn integration-test. A nice technique a colleague suggested is to have a name convention for integration tests and explicitly exclude/include during related phases in the Maven Surefire plugin. Assuming the naming convention referring to classes meant to be Integration Tests have the “IntegrationTest” suffix, the POM configuration of the maven-surefire-plugin would look something like this:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s