2017 October Release

How to Use Apache Ant Tasks with Fabasoft app.testPermanent link for this heading

Apache Ant Task "apptest": Run Tests with the Fabasoft app.test Console PlayerPermanent link for this heading

PrerequisitesPermanent link for this heading

For using Apache Ant, you have to fulfill the following prerequisites:

  • Install Apache Ant on your computer (http://ant.apache.org/bindownload.cgi)
  • Set the following environment variables
    • JAVA_HOME
      Make sure that the environment variable JAVA_HOME is set to the path of the installed Java version which should be used for Fabasoft app.test (Use correct architecture!).
    • ANT_HOME
      Set this environment variable to the installation path of Apache Ant.
    • PATH
      Enhance this environment variable with the path to the "bin" folder in the installation path of Apache Ant (<installation path>/bin).

Create a build.xml FilePermanent link for this heading

First of all you have to define a build.xml file where you specify the targets. In this file you define a project which contains one or more targets:

Syntax

<project name="<project name>" >
   <!--define targets -->
</project>

Afterwards you can define targets.

Syntax

<property name="apptest.dir" value="<path to Fabasoft app.test Infrastructure installation>/anttasks" />
<taskdef classpath="${apptest.dir}/apptest-ant.jar" resource="tasks.properties"/>

With the Apache Ant task "apptest" the Fabasoft app.test Console Player can be started. One or more tests can be started - either sequential or parallel. These are the attributes that can be set:

  • config
    In this attribute you can define a path to a configuration file that should be used for executing the files that have been specified in the task. You do not have to specify a configuration file in each target. You can also specify a configuration file for all tasks in the property apptest.config or define parameters within the task (analog to overwriting parameters when starting the Fabasoft app.test Console Player).
    You do not have to specify a configuration file but can also define all properties needed for starting the Fabasoft app.test Console Player within the Apache Ant task "apptest".
  • verbose
    If you set verbose to true, you can see an output in the console.
  • fork
    • true: All tests within the target are started parallel. Afterwards, the Fabasoft app.test Console Player waits till all tests have finished. In this mode no output is shown in the console window.
    • false: All tests are executed sequentially.

Furthermore, you can define a fileset. In this fileset you can include the files that should be executed (tests, sequences and use cases).
When the Fabasoft app.test Console Player has finished the execution of a target you can read out the values of the variables apptest.error and apptest.exitcode. Note that these variables are only defined if you set fork="false".

If you want to pass test parameters to a test, you can use the nested task parameter. The given parameters are passed to the test as parameter table. If a parameter table is already defined (e.g. via the config ParameterTable.filename; note that the path to the parameter table should be defined absolute), the parameters are merged to the parametrers defined in the parameter tables when passed to the test. Parameters from a parameter table always override passed parameters.

If you want to get test parameters and save it into an ant property you can use the nested task outparameter. Note that this is only possible if exactly one test is executed.

Example

<?xml version="1.0" encoding="utf-8" ?>
<project name="Sample app.test Project">
   <target name="<target name>">
      <property name="apptest.dir" value="<path to Fabasoft app.test Intrastructure installation>/anttasks"/>
      <taskdef classpath="${apptest.dir}/apptest-ant.jar" resource="tasks.properties"/>

      <property name="apptest.config" value="test.config" />

      <apptest verbose="true" fork="true">
         <config key="Config.projectpath" value="." />
         <config key="Agent.hostname" value="127.0.0.1" />
         <config key="Run.clienttype" value="HTML_IE" />
         <fileset dir=".">
            <include name="*.ducx-test" />
         </fileset>
      </apptest>

      <apptest config="test.config2" verbose="true" fork="false">
         <config key="Config.projectpath" value="<path to another project>" />
         <config key="Agent.hostname" value="<another agent hostname>" />
         <config key="Run.clienttype" value="HTML_MOZILLA" />
         <parameter name="<input test parameter name>"
                    value="<parameter value>" />
         <outparameter name="<output test parameter name>"
                       property="<ant property name to store value>" />
         <fileset dir="<path to another project>/Tests">
            <include name="Workflow.ducx-test" />
         </fileset>
      </apptest>

      <echo message="Exit Code: ${apptest.exitcode}" />
      <echo message="Error Message: ${apptest.error}" />
   </target>
</project>

Note: In chapter “Create a build.xml File” you can find an example of a more complicated build.xml file for starting several tests parallel.

Apache Ant Task "apptest-reportsummary": Summarize ReportsPermanent link for this heading

This Apache Ant task allows summarizing several Fabasoft app.test Reports to one single report in a simple way.

Example

<target name="SummarizeMyReports">
   <apptest-reportsummary verbose="true">
      <!-- Define the title of this summary report -->
      <config key="name" value="Reports Version 9.2.3.7" />
      
      <!-- Define the location of this summary report -->
      <config key="result.path" value="D:/Reports" />
      <config key="result.name" value="SummarizedReport923.xml"/>
      
      <!-- Define the stylesheet that should be used to transform this summary report (note: change file ending to .pdf when creating a PDF with a BIRT stylesheet) -->
      <config key="result.transformation" value="SummarizedReport923.html"/>
      <config key="result.stylesheet" value="${apptest.dir}/reportstyles/apptest-errorreport.xsl" />
      <!--
        Useable stylesheets delivered by app.test:
          apptest-errorreport.xsl: Standard transformation to HTML
          apptest-multireportdetail.rptdesign: BIRT transformation to PDF or HTML
      -->
      
      <!-- Define the stylesheet that should be used to transform the fragments (optional) -->
      <config key="fragments.stylesheet" value="${apptest.dir}/reportstyles/apptest-reportdetail.xsl" />
      <config key="fragments.prefix" value="Detail_"/>
      <config key="fragments.suffix" value=".html"/>
      
      <!-- Define level of detail:
        OVERVIEW: Just sequences of all test reports are shown
        ERROR: First error of each test report is displayed + screenshot
        ALL: All test reports with all details and screenshots are shown
      -->
      <config key="level" value="error"/>
      

      <!-- Optional: continue, if a report file contains an error and cannot be processed -->

      <config key="onerror.continue" value="true"/>

      
      <!-- Optional: compress images to reduce file size -->

      <config key="image.compress" value="true"/>

      <!-- Optional: define image compression ratio (0 – 1, 0: highest compression, 1: highest quality; default: 0.5) -->

      <config key="image.compress.ratio" value="0.7"/>

      
      <fileset dir="D:/Reports">
         <include name="**/*.ducx-rep" />
      </fileset>
   </apptest-reportsummary>
</target>

Apache Ant Task "apptest-reporttransformation": Transform app.test reports and external reportsPermanent link for this heading

This Apache Ant task allows transforming several reports with a specified stylesheet, e.g. XSL or BIRT.

Example

<target name="TransformReport">
   <apptest-reporttransformation>
      <!-- Stylesheet for the transformation -->
      <config key="stylesheet" value="${myreportstyles}/BIRTreport.rptdesign" />
      
      <!-- Define transformation parameters -->
      <config key="parameter.CaptionFontSize" value="10" />
      <config key="parameter.CaptionColor" value="red"/>
      
      <!-- Define prefix and suffix of the resulting report -->
      <config key="prefix" value="BIRT_"/>
      <config key="suffix" value=".html" />
      
      <!-- app.test reports to transform -->
      <fileset dir="${reportpath}/trunk">
         <include name="*.ducx-rep"/>
      </fileset>
   </apptest-reporttransformation>
      
   <apptest-reporttransformation>
      <!-- Stylesheet for the transformation -->
      <config key="stylesheet" value="${myreportstyles}/BIRTPerformanceAnalysis.rptdesign" />
      
      <!-- Define transformation parameters -->
      <config key="parameter.CSV_Folder" value="${performancereports}/trunk" />
      
      <!-- Define target file -->
      <config key="target" value="${performancereports}/trunk/BIRT/report.html"/>
   </apptest-reporttransformation>
</target>