Popular Posts

Friday, October 16, 2009

How to pass system properties to maven surefire plugin test run

While developing WSO2 QA test framework (which is based on selenium RC), we wanted to give users the choice of selecting test cases without running whole suite at once. Our plan was to pass a system property during maven test run. However, passing a system property directly through command line does not work since the surefire plugin is run under a different JVM instance that is launched by Maven.
In order to overcome this, maven surefire plugin can be configured as follows by specifying the required system property.

<systemProperties>
<property>
<name>test.suite</name>
<value>${test.suite}</value>
</property>
</systemProperties>

According to this example configuration, we can run test suite with passing a system property as follows.

'mvn clean install -Dtest.suite=test-case'

2 comments:

Henri said...

Another way to do it :

http://jira.codehaus.org/browse/SUREFIRE-121

mvn test -Dtest=myTest -DargLine="-Dtest.suite=test-case"

JC said...

This is now deprecated :
use


${test.suite}