There are two ways to add a list of system properties to Surefire:
This configuration is the replacement of the deprecated systemProperties. It can accept any value from Maven's properties that can be converted to a String value.
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <systemPropertyVariables> <propertyName>propertyValue</propertyName> <buildDirectory>${project.build.directory}</buildDirectory> [...] </systemPropertyVariables> </configuration> </plugin> </plugins> </build> [...] </project>
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <systemProperties> <property> <name>propertyName</name> <value>propertyValue</value> </property> [...] </systemProperties> </configuration> </plugin> </plugins> </build> [...] </project>
Take note that only String typed properties can be passed as system properties. Any attempt to pass any other Maven variable type (e.g. a List or a URL variable) will cause the variable expression to be passed literally (unevaluated). So given the example below:
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <systemProperties> <property> <name>buildDir</name> <value>${project.build.outputDirectory}</value> </property> </systemProperties> </configuration> </plugin> </plugins> </build> [...] </project>
The string ${project.build.outputDirectory} will be passed on literally because the type of that expression is a File, not a String.
To inherit the systemProperties collection from the parent configuration, you will need to specify combine.children="append" on the systemProperties node in the child pom:
<systemProperties combine.children="append"> <property> [...] </property> </systemProperties>