9.11. Maven integration

Table of Contents

9.11.1. Obtaining the Maven Plugin
9.11.2. Installing the Maven Plugin
9.11.3. Using the Maven Plugin
9.11.4. Maven Plugin XML reference

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting, and documentation from a central piece of information.

The Squish Maven plugin described here makes it possible to run Squish tests during any Maven phase.

9.11.1. Obtaining the Maven Plugin

The Maven plugin is available from: download.froglogic.com/resources/squish-maven-plugin_latest.zip

9.11.2. Installing the Maven Plugin

To install the plugin, start by unzipping the package. Once unzipped, change into the package's directory. To perform the installation, on Windows, run the install-squish-plugin.bat program, and on Unix-like systems run the install-squish-plugin.sh program.

9.11.3. Using the Maven Plugin

To use the plugin from your POM file add the squish-plugin to the plugins section:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/maven-v4_0_0.xsd">
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>com.froglogic.squish.maven</groupId>
        <artifactId>squish-plugin</artifactId>
        <executions>
          <execution>
            <id>book-test</id>
            <phase>test</phase>
            <goals>
              <goal>run-test</goal>
            </goals>
            <configuration>
              <path>C:\Squish</path>
              <testsuite>C:\Squish\examples\qt\addressbook\suite_py</testsuite>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

This example runs the suite_py test suite during the test phase and produces the following output:

[INFO] [squish:run-test {execution: book-test}]
[INFO] Squish Maven Plugin version 4.0
[INFO]   path=C:\Squish
[INFO]   testsuite=C:\Squish\examples\qt\addressbook\suite_py
...
[INFO] Tests run : 3, Failures : 0, Errors : 0, Fatals : 0
[INFO] Running test cases took 21 seconds

9.11.4. Maven Plugin XML reference

This section provides an overview of the run-test goal that can be used after installing the Maven plugin.

9.11.4.1. run-test

The run-test goal is used to run an entire Squish test suite or single test cases. The table below shows the elements that can be used within the configuration element:

Table 9.7. run-test goal

Element Description Required
testsuite The absolute path to the Squish suite that is to be run. Yes
testcase Deprecated The one test case from the suite to be run, available for backwards compatibility only. Leave this element out to run the complete test suite. To specify which test cases should be executed explicitly use the testCases element instead. No
path The absolute path to Squish's root directory. Yes
host The hostname of the machine where the squishserver is running. Leave this parameter out to let the plugin start the squishserver automatically. No
port The port number that the squishserver is listening on. Leave this parameter out to let the plugin start the squishserver automatically. No
snoozefactor The snooze factor to use when running Squish tests, defaults to 1. No
reportdir Deprecated The directory where test reports should be output to, available for backwards compatibility only. To generate reports use the reports element instead. No
resultDir The absolute path to a directory which is used to save test results, corresponds to the squishrunner's --resultdir which is documented at Executing a Test Case (Advanced) (Section 7.4.3.24). No
squishReport Deprecated The file name of the Squish XML report which is saved in the resultDir folder, available for backwards compatibility only. To generate the Squish XML report use the reports element instead. No
junitReport Deprecated The file name of the Squish JUnit report which is saved in the resultDir folder, available for backwards compatibility only. To generate the Squish JUnit report use the reports element instead. No
webbrowser When executing a web test the browser to be used. Supported values are listed at the squishrunner's --webbrowser option at Executing a Test Case (Advanced) (Section 7.4.3.24). No
webbrowserargs When executing a web test the command line arguments passed to the used browser. No
ignoreFatals Don't throw an exception if the Squish test contains errors or fatals to avoid aborting the Maven execution, defaults to false can be set to true. No
ignoreFails Don't throw an exception if the Squish test contains fails to avoid aborting the Maven execution, defaults to true can be set to false. No
abortOnFail Throw an exception if the Squish test contains failures to abort the Squish Tests execution, defaults to false can be set to true. No


9.11.4.2. testCases

The testCases element can be used to specify which test cases should be executed. Leave this element out to run the complete test suite.

Table 9.8. run-test goal

Element Description
testCases Contains testCase elements as children.
testCase Name of the test case to be executed, must be a child of the testCases element.


Here is an example of using the testCases element in a POM file:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/maven-v4_0_0.xsd">
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>com.froglogic.squish.maven</groupId>
        <artifactId>squish-plugin</artifactId>
        <executions>
          <execution>
            <id>book-test</id>
            <phase>test</phase>
            <goals>
              <goal>run-test</goal>
            </goals>
            <configuration>
              <path>C:\Squish</path>
              <testsuite>C:\Squish\examples\qt\addressbook\suite_py</testsuite>
              <testCases>
                <testCase>tst_adding</testCase>
                <testCase>tst_general</testCase>
              </testCases>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

9.11.4.3. tagFilters

The tagFilters element can be used to execute just those test scripts or BDD scenarios which match a given tag filter. Leave this element out to run the complete test suite.

Table 9.9. run-test goal

Element Description
tagFilters Contains tags elements as children.
tags Tags of Test Cases to be executed. Semantics is the same as for --tags parameter for squishrunner. Must be a child of the tagFilters element.


Here is an example of using the tagFilters element in a POM file, where all scenarios or test scripts tagged both foo and bar are executed.

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/maven-v4_0_0.xsd">
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>com.froglogic.squish.maven</groupId>
        <artifactId>squish-plugin</artifactId>
        <executions>
          <execution>
            <id>book-test</id>
            <phase>test</phase>
            <goals>
              <goal>run-test</goal>
            </goals>
            <configuration>
              <path>C:\Squish</path>
              <testsuite>C:\Squish\examples\qt\addressbook\suite_py</testsuite>
              <tagFilters>
                <tags>foo</tags>
                <tags>bar</tags>
              </tagFilters>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

9.11.4.4. scriptArgs

The scriptArgs element can be used to pass script arguments to a test script. This is similar to using --scriptArgs parameter for squishrunner.

Table 9.10. Scripting arguments

Element Description
scriptArgs Contains arg elements as children.
arg Contains argument to be passed to a test script. Must be a child of the scriptArgs element.


Here is an example of using the scriptArgs element in a POM file.

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/maven-v4_0_0.xsd">
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>com.froglogic.squish.maven</groupId>
        <artifactId>squish-plugin</artifactId>
        <executions>
          <execution>
            <id>book-test</id>
            <phase>test</phase>
            <goals>
              <goal>run-test</goal>
            </goals>
            <configuration>
              <path>C:\Squish</path>
              <testsuite>C:\Squish\examples\qt\addressbook\suite_py</testsuite>
              <scriptArgs>
                <arg>--username</arg>
                <arg>Tomasz</arg>
              </scriptArgs>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

9.11.4.5. reports

The reports element can be used to specify Squish reports to be generated.

Table 9.11. run-test goal

Element Description
reports Contains report elements as children.
report Configures a single report by providing format and path elements as children.
format Report format to be generated. Supported values are listed at the squishrunner's --reportgen option at Executing a Test Case (Advanced) (Section 7.4.3.24).
path The absolute path to the report file to be generated.


Here is an example of using the reports element in a POM file:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/maven-v4_0_0.xsd">
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>com.froglogic.squish.maven</groupId>
        <artifactId>squish-plugin</artifactId>
        <executions>
          <execution>
            <id>book-test</id>
            <phase>test</phase>
            <goals>
              <goal>run-test</goal>
            </goals>
            <configuration>
              <path>C:\Squish</path>
              <testsuite>C:\Squish\examples\qt\addressbook\suite_py</testsuite>
              <testCases>
                <testCase>tst_adding</testCase>
                <testCase>tst_general</testCase>
              </testCases>
              <reports>
                <report>
                  <format>xml2.2</format>
                  <path>C:\xml_reports\addressbook.xml</path>
                </report>
                <report>
                  <format>xmljunit</format>
                  <path>C:\junit_reports\addressbook.xml</path>
                </report>
              </reports>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>