Before you can use the Parasoft Test Maven plugin, you need to add the http://build.parasoft.com/maven repository to your POM or repository manager. For instance:
<project>
...
<pluginRepositories>
<pluginRepository>
<id>Parasoft</id>
<url>http://build.parasoft.com/maven</url>
</pluginRepository>
</pluginRepositories>
...
</project>
If you will be performing Jtest unit testing from Maven, you also need to add the build artifacts in the http://build.parasoft.com/maven/Parasoft/jtest repository to your POM or repository manager. For instance:
<project>
...
<dependencies>
...
<dependency>
<groupId>Parasoft</groupId>
<artifactId>jtest</artifactId>
<version>9.5.0/version> <!-- See below for available versions -->
</dependency>
...
</dependencies>
...
<repositories>
<repository>
<id>Parasoft</id>
<url>http://build.parasoft.com/maven/</url>
</repository>
</repositories>
...
</project>
If you extend the POM, the specified goals will always be run at a particular phase of the build lifecycle. This allows you to specify your configuration once, and have it used every time that Maven builds the configured project.
<project>
...
<build>
<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>Parasoft</groupId>
<artifactId>maven-parasoft-plugin</artifactId>
<version>3.0</version>
</plugin>
...
</plugins>
</pluginManagement>
<!-- To use the plugin goals in your POM or parent POM -->
<plugins>
<plugin>
<groupId>Parasoft</groupId>
<artifactId>maven-parasoft-plugin</artifactId>
<version>3.0</version>
</plugin>
...
</plugins>
</build>
...
</project>
Next, specify goals and configuration parameters. For example, the following runs the eclipse and
jtest goals during the
test lifecycle phase (Jtest is run with the built-in Static Analysis Test Configuration):
<project>
...
<build>
<plugins>
<plugin>
<groupId>Parasoft</groupId>
<artifactId>maven-parasoft-plugin</artifactId>
<version>3.0</version>
<configuration>
<config>builtin://Static Analysis</config>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>eclipse</goal>
<goal>jtest</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
...
</project>
The most direct way to execute the plugin is to configure the plugin execution details completely from the command line. For example, to invoke the
jtest goal from the sample POM (above), you would go to the project’s command line and use
To simplify calling the plugin from the command line, we strongly recommend that you modify the settings.xml file (
~/.m2/settings.xml) to include a Parasoft plugin group that specifies the appropriate groupids, artifactids, and goals. For example:
<settings>
<pluginGroups>
<pluginGroup>Parasoft</pluginGroup>
</pluginGroups>
</settings>
This will tell Maven where to search for the plugin—allowing you to shorten the above command line invocation to
Another tip for simplifying your command line invocation is to specify some options in the POM. For instance, if you are invoking
jtest-global from the command line, you could set the desired test configuration, localsettings file, etc. in the POM.
A third option is to add a switch within a profile, then run with the appropriate switch when you want to apply one of the Parasoft goals. You can configure any number of switches with different goals and parameters. This approach is useful for when you want to set plugin execution details in the POM, but you do not want it permanently attached to a lifecycle phase. It is also useful if you want configure a set of different plugin configurations, then select the appropriate one at the command line invocation.
For example, you can add a jtest profile to the build as follows:
<profiles>
<profile>
<id>jtest</id>
<build>
<plugins>
<plugin>
<groupId>Parasoft</groupId>
<artifactId>maven-parasoft-plugin</artifactId>
<configuration>
<config>builtin://Static Analysis</config>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>eclipse</goal>
<goal>jtest</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
You can then use mvn install -Pjtest to run the
jtest profile.
These options are typically used when running the plugin via the command line—because some parameters can't be set in the command line (like those of type List). For example, the
vmargs parameter of
parasoft:jtest is of type List and can be used for things like changing the user name or increasing Java memory.
In order to execute Jtest, you need to have .classpath and
.project files that work in the server environment. In order to execute SOAtest, you need to have a
.project file that works in the server environment. To generate the files that Eclipse requires, use
parasoft:eclipse.
If you have decided to store localsettings for Jtest and SOAtest execution on Concerto (as described in the Concerto documentation)—and/or if you are specifying localsettings options in the POM—
parasoft:localsettings will generate a localsettings file with these options, then save it in the project so that it can easily be used for your Maven-driven tests.
If you have a multi-module project (with modules that get built individually), the parasoft:jtest goal will run once for each project module. If you want a single Jtest run to analyze your entire project (for instance, for more accurate application of project-wide static analysis rules or to optimize execution time), use
parasoft:jtest-global instead of
parasoft:jtest.
Note that jtest-global must be invoked at the command line since it can’t be bound to any specific Maven lifecycle phase.
The parasoft:compile goal executes the Parasoft Build Monitor, which analyzes your build and sends Parasoft Concerto data regarding build warnings, errors, and the number of files successfully compiled. This is performed as part of the compile lifecycle phase.
To use this goal, go to your project’s POM file and add the following plugin instruction to your <build><plugins> node:
<plugin>
<groupId>Parasoft</groupId>
<artifactId>maven-parasoft-plugin/artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>1.4</source>
<target>1.4</target>
<enableGRS>true</enableGRS>
<showDeprecation>true</showDeprecation>
<grsServerName>server.parasoft.com</grsServerName>
<grsServerPort>32323</grsServerPort>
<grsAttributes>
<attribute>test1=value1</attribute>
<attribute>test2=value2</attribute>
<attribute>test3=value3</attribute>
</grsAttributes>
</configuration>
</plugin>
To invoke Build Monitor with a compiler, run mvn parasoft:compile.
Notes: