XML scenario syntax

A test scenario is an XML document that follows the structure described by the rtest.xsd application schema. This application schema greatly simplifies the editing of the test scenario using an XML editor such as XMLSpy, OxygenXML or others. These tools allow for quick detection of input errors and even offer writing assistance. It is important to use a powerful tool to avoid wasting unnecessary time when editing test scenarios.

The rest of this document describes the different elements that can be found in a test scenario. The notation used is the following: /element1/element2@attr1 Where:

  • /element1 is the root element of the document (scenario)

  • element2 corresponds to an element contained in element1

  • attr1 is an attribute of element2

Warning

The case and order of the elements must be respected.

Scenario

/scenario

  • Required element

  • Description: <scenario> is the root element of all scenarios. Its content is fixed (example scenario), only the xsi:schemaLocation attribute can be modified.

<scenario xmlns="http://www.veremes.com/rtest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.veremes.com/rtest http://schemas.veremes.net/rtest/2.0/rtest.xsd">

/scenario@xsi:schemaLocation

  • Optional attribute - useful for Editing

  • Description: The xsi:schemaLocation attribute of the element is used to describe the location of the reference application schema.

  • Default value :

xsi:schemaLocation="http://www.veremes.com/rtest http://schemas.veremes.net/rtest/2.0/rtest.xsd"

This indicates that the XML editor must rely on the application schema version located at http://schemas.veremes.net/rtest/2.0/rtest.xsd

To work without an internet connection or to adapt the schema to your own needs, it is possible to copy rtest.xsd to the local directory and reference it as follows:

xsi:schemaLocation="http://www.veremes.com/rtest ./rtest.xsd"

/scenario/project

  • Optional element

  • Description: Name of the project to which the test scenario belongs. This value is used for display in the html report.

/scenario/description

  • Optional element

  • Description: Description of the test scenario. This value is used for display in the html report.

/scenario/rtestCollection

  • Required element

  • Description : Collection of elements of type <rtest>.

/scenario/rtestCollection/rtest

  • Required element

  • Description: This element groups together all the information needed to describe a test. It is possible to describe one or more elements consecutively.

/scenario/rtestCollection/rtest@id

  • Required attribute

  • Description: Each rtest element has an id attribute that allows it to be uniquely identified within the same scenario. The id attribute is of type xs:ID, so it must follow the following rules:

    • it must start with a letter.

    • it must not contain spaces, carriage returns or special characters other than the period.

    • it must be unique in the dataset.

/scenario/rtestCollection/rtest@label

  • Optional attribute

  • Description: Name of the test. This value is used for display in the html report.

label="Point in a donut (Switzerland)"

Process

/scenario/rtestCollection/rtest/processCollection

  • Optional element

  • Description : Collection of elements of type <process>

/scenario/rtestCollection/rtest/processCollection/process

  • Element required inside <processCollection>

  • Description: This element groups together all the information necessary for the description of an FME workspace (process). It is possible to describe one or more elements consecutively.

/scenario/rtestCollection/rtest/processCollection/process@deletebefore

/scenario/rtestCollection/rtest/processCollection/process@deleteafter

  • Optional attribute

  • Description: These attributes list the files to be deleted before or after the FME processing is executed. The paths can be absolute or relative to the test scecnario. If there are multiple files, they must be separated by a comma. Patterns are supported. The following example shows how to delete the dbcountry.sqlite file contained in the result directory and all files with the .log extension.

<process deletebefore="./result/dbcountry.sqlite,./result/*.log">

Caution

If a file is locked, deletion fails and scenarioPlayer stops. A file can be used and locked by FME when running the scenarioPlayer. If this happens, you should change the file name for successive tests in the same test scenario or separate the tests in different scenarios. To reduce the risk of unintentional deletion in the event of incorrect settings, the number of files that can be deleted by a single reason is limited to 20. If such a case is detected, scenarioPlayer stops and an error message is added to the log file. Despite this limitation, you should be very careful when using the deletebefore and deleteafter parameters.

/scenario/rtestCollection/rtest/processCollection/process@waitbefore

/scenario/rtestCollection/rtest/processCollection/process@waitafter

  • Optional attribute

  • Description: These attributes define a waiting time (in seconds) before or after the FME processing is executed. They should be used when testing a complex integration chain in asynchronous mode. For example, when FME processing subcontracts some tasks to FME Server or WorkspaceRunner in asynchronous mode (without waiting for the processing to finish).

  • Expected value: An integer.

  • Example: The following process must wait 1 minute before it is executed.

<process waitbefore="60" >

/scenario/rtestCollection/rtest/processCollection/process@label

  • Optional element

  • Description: Description of the FME processing and its parameters. This value is used for display in the HTML report.

/scenario/rtestCollection/rtest/processCollection/process/workspace

  • Required element

  • Description: Name and path of the FME processing to be executed. The path can be absolute or relative to the test scenario.

  • Expected value: Path to an FME project in .fmw format

  • Example:

<workspace>./HelloWorld.fmw</workspace>

/scenario/rtestCollection/rtest/processCollection/process/expectedstatus

  • Optional element

  • Description: Allows you to specify whether the expected result is the success or failure of the workspace: Translation FAILED or Translation was SUCCESSFUL. It is sometimes useful to check that the use of certain parameters causes the processing to fail on purpose. So if the expected status is failure and the processing fails, then the html report will show a successful test.

  • Expected value: [failure|success], default is success

/scenario/rtestCollection/rtest/processCollection/process@copylogto

  • Optional attribute

  • Description: Allows to force the copy of the processing log file in a directory and under a known name. This technique allows a later inspection of the log content during a verification operation.

  • Expected value: Absolute or relative path of the file to be produced.

  • Example:

<process copylogto="./result/helloworld.log" >

/scenario/rtestCollection/rtest/processCollection/process/parameterCollection

  • Optional element

  • Description: This element contains the collection of all FME processing <parameter>.

/scenario/rtestCollection/rtest/processCollection/process/parameterCollection/parameter

  • Required element inside <parameterCollection>

  • Description: One of the parameters of the FME processing. Each parameter is described by its two attributes name and value.

  • Example:

<parameter name="xy" value="-123.0 49.1"/>
<parameter name="destShpDir" value="./result/country.zip"/>

/scenario/rtestCollection/rtest/processCollection/process/parameterCollection/parameter@name

  • Required attribute

  • Description: Name of the FME parameter. This must be case sensitive.

/scenario/rtestCollection/rtest/processCollection/process/parameterCollection/parameter@value

  • Required attribute

  • Description: FME parameter value.


Checks

/scenario/rtestCollection/rtest/checkCollection

  • Optional element

  • Description : Collection of elements of type <check>

/scenario/rtestCollection/rtest/checkCollection/check

  • Element required inside <checkCollection>

  • Description: This element groups together all the information needed to describe a check. It is possible to describe one or more <check>elements consecutively.

/scenario/rtestCollection/rtest/checkCollection/check@label

  • Optional element

  • Description: Description of the audit. This value is used for display in the html report.

/scenario/rtestCollection/rtest/checkCollection/check/source

  • Required element

  • Description: The element is used to calculate the value to be checked, also known as the "Observed Value". The observed value comes from a dataset. Depending on the type of dataset, it can be for example the number of records, the value of an attribute, the size of a file or the result of an SQL query.

/scenario/rtestCollection/rtest/checkCollection/check/source@type

  • Required attribute

  • Description: The source@type attribute defines the type of data source to be read to obtain the observed value. There are three possible types: file, datafile and database.

Type file

When scenarioPlayer encounters a data source of type file it does not try to open it but only looks at its external characteristics such as size or creation date. Currently the only function available on file data sources is fileSize() which returns the file size (in bytes) as the observed value.

Type datafile

Data sources of type datafile must be associated with a format (cf.source@format). They can then be read by scenarioPlayer with the correct FME Reader. The functions available to calculate the value observed on this type of files are : featuresCount(), attributeValue(), featuresCountByFtAndGeometry()

Type logfile

The logfile type is used to search for a pattern in a text file. It is not necessary to specify the format of the dataset. The source@dataset is read line by line and each line is compared with the expected value. If at least one line matches, the validation is set to "Success", otherwise it is set to "Failed". The match comparator is well suited to handle this type of file by allowing a comparison pattern to be defined in condition@expectedvalue. The logfile type is frequently associated with the process@copylogto attribute which allows to create a copy of the FME processing log file. This makes it possible to search for a pattern in a file of this type.

Type database

Finally, database data sources allow to execute a SQL query on the dataset to extract the desired information. This is the most powerful mechanism for defining a check on the attribute or geometric content of a dataset.

Note

The location of the dataset, its format, and the observed value are determined by the other attributes of the element.

/scenario/rtestCollection/rtest/checkCollection/check/source@format

  • Required attribute for datafile sources

  • Description: Format to be used to read the source dataset identified by the source@dataset attribute. The list of supported formats may evolve with the versions of scenarioPlayer.

  • Expected value: Short name of the FME format visible in the "View Format Gallery" menu of FME Workbench. Not all formats are supported, see the list of usable formats.

/scenario/rtestCollection/rtest/checkCollection/check/source@dataset

  • Required attribute for datafile sources

  • Description: Defines the location of the dataset. The path can be absolute or relative to the test scenario.

  • Example:

<source type="datafile" format="ESRISHAPE" dataset="./result/country.zip" request="featuresCount()" requestparams="country"/>

/scenario/rtestCollection/rtest/checkCollection/check/source@request

  • Attribute required for datafile and file sources

  • Description: Defines the function called to calculate the observed value.

  • Expected value :

    • For datasets of type file :

      • filesize()

    • For datasets of type datafile :

      • featuresCount()

      • attributeValue()

      • featuresCountByFtAndGeometry()

The behavior of each function is described in functions and parameters

  • Example:

<source type="file" dataset="result\dbcountry.sqlite" request="fileSize()"/>

/scenario/rtestCollection/rtest/checkCollection/check/source@dbrequest

  • Required attribute for database sources

  • Description: SQL query to be applied to the source dataset and to calculate the observed value observedvalue.

  • Expected Value: A string corresponding to a SQL query for the source dataset. The query must return a single value in the form of an "observedvalue" field. The spelling of "observedvalue" must be lowercase, but to simplify the writing of Oracle queries, OBSERVEDVALUE fields with this format are automatically converted to lowercase.

  • Examples :

For data set SPATIALITE

<source type="database" format="SPATIALITE" dataset="result\dbcountry.sqlite" dbrequest="select name as observedvalue from country where OGC_FID=2;"/>

For data set POSTGIS

<source type="database" format="POSTGIS" connection="nc_mabase" dbrequest="SELECT ST_Extent(geom) as observedvalue FROM departements.dpt_postgis;"/>
<condition comparator="eq" expectedvalue="BOX(47700 1616600,1197900 2677200)"/>

For data set ORACLE_SPATIAL

  <source type="database" format="ORACLE_SPATIAL" connection="nc_dpt_oracle" dbrequest="FME_SQL_DELIMITER ; SELECT CONCAT(NUM_DEP, NOM_DEP) AS observedvalue FROM ADM.DPT WHERE num_dep='66';"/>
  <condition comparator="eq" expectedvalue="66PYRENEES-ORIENTALES"/>

/scenario/rtestCollection/rtest/checkCollection/check/source@requestparams

  • Optional attribute, required with some request values

  • Description: requestparams should be used to refine the scope of the function called in the request attribute. For example requestparams will allow to define the name of the attribute and the index of the record concerned by the attributeValue() function.

  • Expected value: Depends on the value of the check@request attribute. See Test Operators and Parameters

/scenario/rtestCollection/rtest/checkCollection/check/condition

  • Required element

  • Description: The <condition> element is used to define the reference value or "Expected Value" that should be compared to the observed value defined in the <source> element. It also defines the operator to be used to compare the two values.

/scenario/rtestCollection/rtest/checkCollection/check/condition@comparator

  • Required attribute

  • Description: Operator allowing to compare the observed value and the expected value.

    • eq : equal to

    • noeq: different from

    • gt: greater than

    • lt: less than

    • gtoe: greater than or equal to

    • ltoe : less than or equal to

    • match : check the regular expression

    • in range : in the value range

    • in list : in the value list

  • Examples :

The observed value must be "Switzerland".

<condition comparator="eq" expectedvalue="Switzerland"/>

The observed value must start with "Switz".

<condition comparator="match" expectedvalue="^Switz"/>

The observed value must be numerical and between 5630000 and 5645000.

<condition comparator="in range" expectedvalue="[5630000,5645000]"/>

The observed value must be "Switzerland" or "Canada".

<condition comparator="in list" expectedvalue="(Switzerland,Canada)"/>

/scenario/rtestCollection/rtest/checkCollection/check/condition@expectedvalue

  • Required attribute

  • Description : Expected value. This value depends on the operator used.

    • in range : expectedvalue must be in the form [min,max]

    • in list : expectedvalue must be a list of values in the form (value1,value2,...)

    • match : expectedvalue must be a regular expression

    • lt, gt, ltoe, gtoe : expectedvalue must be a numeric value

    • all other operators: string