You have several execution tags in the configuration of the maven-surefire-plugin, i.e. the goal test is executed several times in the default phase test. Actually, your plugin configuration leads to 3 test exections:
- default-test (triggered automatically by surefire, no custom system property set)
- before-run (as defined first in your POM, system property set)
- main-run (as defined second in your POM, system property set)
mvn test with Maven 3.5.4:
------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.example.app.ExampleTest getProperty:null Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.078 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-surefire-plugin:2.14.1:test (before-run) @ app --- [INFO] ... ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.example.app.ExampleTest getProperty:aaa Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.078 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-surefire-plugin:2.14.1:test (main-run) @ app --- [INFO] ... ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.example.app.ExampleTest getProperty:bbb Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.078 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
Consider overriding the default-test execution in order to apply your configuration properly. Example:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.14.1</version> <executions> <execution> <id>before-run</id> ... </execution> <execution> <id>default-test</id> ... </execution> </executions>