Unit Testing: Define System Properties

Maven Surefire Plugin is a the plugin responsible for executing the unit tests. One very convenient feature is the possibility to define (in the pom.xml) the system properties and make those available to the Java test classes:

<!-- define system properties -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>jndi_unit_test_helper</name>
                            <value>${jndi_unit_test_helper}</value>
                        </property>
                        <property>
                            <name>ContainerLibDir</name>
                            <value>${ContainerLibDir}</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>

See how 2 system properties “jndi_unit_test_helper” and “ContainerLibDir” have been defined and initialised (the actual values are defined in the profiles.xml file).

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: