Maven integration

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.

Obtaining the Maven Plugin

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

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.

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

Maven Plugin XML reference

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

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:

ElementDescriptionRequired
testsuiteThe absolute path to the Squish suite that is to be run.Yes
testcaseDeprecated 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
pathThe absolute path to Squish's root directory.Yes
hostThe hostname of the machine where the squishserver is running. Leave this parameter out to let the plugin start the squishserver automatically.No
portThe port number that the squishserver is listening on. Leave this parameter out to let the plugin start the squishserver automatically.No
snoozefactorThe snooze factor to use when running Squish tests, defaults to 1.No
reportdirDeprecated The directory where test reports should be output to, available for backwards compatibility only. To generate reports use the reports element instead.No
resultDirThe 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).No
squishReportDeprecated 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
junitReportDeprecated 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
webbrowserWhen 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).No
webbrowserargsWhen executing a web test the command line arguments passed to the used browser.No
ignoreFatalsDon'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
ignoreFailsDon'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
abortOnFailThrow an exception if the Squish test contains failures to abort the Squish Tests execution, defaults to false can be set to true.No

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.

ElementDescription
testCasesContains testCase elements as children.
testCaseName 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>

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.

ElementDescription
tagFiltersContains tags elements as children.
tagsTags 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>

scriptArgs

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

ElementDescription
scriptArgsContains arg elements as children.
argContains 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>

reports

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

ElementDescription
reportsContains report elements as children.
reportConfigures a single report by providing format and path elements as children.
formatReport format to be generated. Supported values are listed at the squishrunner's --reportgen option at Executing a Test Case (Advanced).
pathThe 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>

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.