9.5. CruiseControl integration

Table of Contents

9.5.1. Obtaining the CruiseControl Plugin
9.5.2. Installing the CruiseControl Plugin
9.5.3. Using the CruiseControl Plugin
9.5.4. CruiseControl XML reference

CruiseControl is a framework that supports a continuous build and integration process. It includes, but is not limited to, plugins for email notification, Ant and various source control tools. A web interface is provided to view the details of the current and previous builds.

It is possible to run Squish tests from a CruiseControl continuous build using the plugin described here.

9.5.1. Obtaining the CruiseControl Plugin

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

9.5.2. Installing the CruiseControl Plugin

To install the plugin simply unzip the zip file and copy the jar files to CC_HOME\lib

9.5.3. Using the CruiseControl Plugin

Here is the example used in the CruiseControl distribution:


<cruisecontrol>
  <project name="connectfour">

    <property environment="env" />

    <listeners>
      <currentbuildstatuslistener file="logs/${project.name}/status.txt" />
    </listeners>

    <bootstrappers>
      <antbootstrapper anthome="${env.ANT_HOME}" buildfile="projects/${project.name}/build.xml" target="clean" />
    </bootstrappers>

    <modificationset quietperiod="30">
      <!-- touch any file in connectfour project to trigger a build -->
      <filesystem folder="projects/${project.name}" />
    </modificationset>

    <schedule interval="300">
      <ant anthome="${env.ANT_HOME}" buildfile="projects/${project.name}/build.xml" />
    </schedule>

    <log>
      <merge dir="projects/${project.name}/target/test-results" />
    </log>

    <publishers>
      <onsuccess>
        <artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/${project.name}.jar" />
      </onsuccess>
    </publishers>

  </project>
</cruisecontrol>

The Squish CruiseControl plugin must be declared before using it. The best way to do this is to declare it as the project's first child. If we apply this to the example shown above, the first few lines will now look like this:

<cruisecontrol>
  <project name="connectfour">

    <plugin name="squishtest" classname="com.froglogic.squish.cc.builders.SquishTestBuilder" />
  ...

To run a Squish test, the following change must be made to the schedule section:

    ...
    <schedule interval="300">
      <composite>
        <ant anthome="${env.ANT_HOME}" buildfile="projects/${project.name}/build.xml" />
        <squishtest
          suite="C:\Squish\examples\qt\addressbook\suite_py"
          path="C:\Squish" />
      </composite>
    </schedule>
    ...

The composite is needed since we have multiple tasks in this case—the ant build file is executed and a Squish test is run. Note that it is also possible to do the squishtest first or to use squishtest more than once in order to run multiple test suites.

9.5.4. CruiseControl XML reference

This section provides an overview of the tags that can be used after installing the CruiseControl plugin.

9.5.4.1. squishtest

The squishtest tag can be used to run Squish test cases or a test suite. The table below shows the attributes that can be used:

Table 9.4. squishtest tag

Attribute Description Required
suite 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 attribute out to run the complete test suite. To specify which test cases should be executed explicitly use the testcase (Section 9.5.4.2) element instead. No
path The absolute path to Squish's root directory. Only if not set in the squishtest tag.
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 report (Section 9.5.4.3) 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
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
failOnVerificationFail If set to 'yes' the build will be marked as failure if Squish verifications fail or an error occurred inside the test execution. Defaults to 'no'. No


[Note]Note

When the attributes mentioned in the table are set in the Squish plugin binding tag, they act as default values. This means that the attributes are inherited from the plugin tag and can be overridden if necessary in the squishtest tag.

9.5.4.2. testcase

The testcase tag can be used to specify which test cases should be executed explicitly. It must be a child of the squishtest tag.

Table 9.5. testcase tag

Attribute Description Required
name Name of the test case to be executed. Yes


Here is an example of using the testcase tag in a CruiseControl configuration file:

<cruisecontrol>
  <project name="connectfour">
    ...
    <schedule interval="300">
      <composite>
        <ant anthome="${env.ANT_HOME}" buildfile="projects/${project.name}/build.xml" />
        <squishtest
          suite="C:\Squish\examples\qt\addressbook\suite_py"
          path="C:\Squish">
          <testcases>
            <testcase name="tst_adding" />
            <testcase name="tst_general" />
          </testcases>
        </squishtest>
      </composite>
    </schedule>
    ...

9.5.4.3. report

The report tag can be used to specify which reports should be generated. It must be a child of the squishtest tag.

Table 9.6. report tag

Attribute Description Required
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). Yes
file The absolute path to a file which the report is written to. Yes


Here is an example of using the report tag in a CruiseControl configuration file:

<cruisecontrol>
  <project name="connectfour">
    ...
    <schedule interval="300">
      <composite>
        <ant anthome="${env.ANT_HOME}" buildfile="projects/${project.name}/build.xml" />
        <squishtest
          suite="C:\Squish\examples\qt\addressbook\suite_py"
          path="C:\Squish">
          <testcases>
            <testcase name="tst_adding" />
            <testcase name="tst_general" />
          </testcases>
          <reports>
            <report format="xml2.2" file="C:\xml_reports\addressbook.xml" />
            <report format="xmljunit" file="C:\junit_reports\addressbook.xml" />
          </reports>
        </squishtest>
      </composite>
    </schedule>
    ...