Java - How to configure Surefire integration

Problem

The Plugin Engine detects an invalid Surefire configuration

Cause

Overridden argLine

The below is handled automatically when using the automatic pom integration (Scanning Builds and Tests using SeaLights Maven plugin - Automatic configuration) with build scanner 2.0.1045 and up

By default, the SeaLights Maven plugin sets the argLine used by Surefire to include the SealIghts test listener as a javaagent. If the Surefire argLine is overridden, then the SeaLights argLine will not be used and hence test information will not be captured.

Solution

For this, the SeaLights Maven plugin also generates a property called sealightsArgLine, which can be placed in the Surefire argLine for easy configuration.
Note: Using of @{sealightsArgLine} demands minimum surefire-plugin version 2.17

Here is a sample configuration for Surefire with the updated argLine at line 8:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${surefire-plugin.version}</version> <configuration> <argLine>-Xms512m -Xmx1024m @{sealightsArgLine}</argLine> </configuration> ...

You can set an empty property called sealightsArgLine so that the build will not fail when the SeaLights maven plugin doesn't run

<properties> ... <sealightsArgLine></sealightsArgLine> </properties>