Using PureTest with Ant

Typically a product life cycle includes several releases. This could be bug releases and releases where a new function has been added. Every release includes time consuming and costly re-test activities. The concept of Automatic regression test aims to reduce the cost and time for these tests.

PureTest include tools supporting this. Together with an Apache Ant task the regression test can be integrated into the build process. The Ant task included PureTest is capable of running any Scenario. It may be configured to log errors and/or execution times.

An example: Testing a web based application

Preparing the Scenario

Start by creating a scenario using the HTTP recorder and the Scenario Editor of PureTest.

  • Start the HTTP recorder included in PureTest.
  • Start a Web browser set to use the HTTP recorder as a proxy.
  • Now the browser is used to browse the web based application that is subject to test. Forms are filled in, content is posted or whatever is going to be tested.
  • During the session the HTTP recorder is recording all the operations between the browser and the application.

When the Scenario has been recorded it is copied to the Scenario Editor and changed to fulfil the requirements of the test. As an example this could be to include a check of the occurrence of a String 'Operation Successful' in the response received as a result of a HTTP request.

The resulting scenario is saved to a file. In this example named 'test.plc.'

Regression test with Ant

The Scenario now contains a complete test case for your web application. When making a new release of the web application you would most certainly like to re test it before releasing it to the public. This may be done manually but you'll save a lot of time using automatic testing. Following is an example how to use the Ant task for this purpose.

Defining the ant build file 

Prepare an ant build file (build.xml) as follows:

<!-- Define PureTest installation directory  -->
<!-- NOTE: Update to match your installation -->
<property name="puretest.home" location=".."/>

<!-- Define class path based on the above -->
<path id="puretest.path">
  <fileset dir="/lib">
    <include name="**/*.jar"/>

<!-- Define scenario-runner task -->
<taskdef name="scenario-runner" classpathref="puretest.path"

<!-- scenario-runner test targets -->
<target name="test">
  <scenario-runner classpathref="puretest.path"

For details on the scenario-runner Ant task see PureTest Documentation.

Running the test

The build file is now prepared. The regression test may now be executed:

% ant test
Buildfile: build.xml

[scenario-runner] Executing 1 'Minq Tests' ... 669 [ms], 1 OK, 0 failed, 0 timeout

Total time: 6 seconds

As seen the test was successful. The web application has now been tested and can be released! By use of the technique it is possible to save a lot tedious testing time. If ant is used in the build phase of your project it is even possible to include the regression test in the build process.

Note: The use of Ant to perform the test is not mandatory. The PureTest distribution includes a command line utility for running scenarios. The Ant task is in fact an Ant wrapping of this utility. See the PureTest documentation for more information.

PureLoad Version: 5.1.3
Release Notes