Ignores

As explained in section Automated Tests with Larva, Larva-tests verify if values that are read from the tested Frank configuration are equal to the expected constant values. However, some tested systems produce different results each time that they are executed, even though the inputs are the same. Examples are systems that return a time stamp. In Larva, you can address this issue using ignores. With ignores, values returned from the tested system are transformed, before they are compared to the expected value. As a Frank developer, you have to choose these transformations wisely and retain meaningful aspects of your returned value.

This section gives an overview of the transformations (ignores) that are available to you. Below is an overview table followed by explanation and examples for every transformation.

Overview
Options Description
ignoreRegularExpressionKey

Replaces all occurrences of regular expression with

IGNORE

ignoreKey

Replaces all matching occurrences of provided key with

IGNORE

ignoreContentBetweenKeys

Replaces all characters found between key1 and key2,

excluding key1 and key2, with IGNORE

ignoreKeysAndContentBetweenKeys

Replaces all characters found between key1 and key2,

including key1 and key2, with IGNORE

ignoreContentBeforeKey Ignores everything before provided key has been found
ignoreContentAfterKey Ignores everything after provided key has been found
ignoreCurrentTimeBetweenKeys Ignore current time between key1 and key2
replaceRegularExpressionKeys

Replaces all matches of regular expression (key1) with

the value of key2

replaceKey

Replaces all matches occurrences of provided key with

provided value

replaceEverywhereKey

Replaces all matches occurrences of provided key with

provided value, same as replaceKey

removeRegularExpressionKey Replaces all matches of regular expression with “”
removeKeysAndContentBetweenKeys

Removes all characters found between key1 and key2,

including key1 and key2

removeKey Removes all matching occurrences of provided key
decodeUnzipContentBetweenKeys Decode and unzip content between key1 and key2
canonicaliseFilePathContentBetweenKeys Canonicalise filepath content between key1 and key2
formatDecimalContentBetweenKeys Format decimal content between key1 and key2

The ignores use the following structure: <ignoreOption><numberOrName>.key=<text>.

Some ignores require 2 keys to indicate start and end, which are denoted as key1 and key2. Both require the same identifier. The <numberOrName> is an increasing sequence of integers starting at 1 for each ignore or an string starting with a “.”. The <text> indicates what to look for.

Usually those ignores are written in the common.properties file where you define your services (see section Services), in this way they apply to all test scenarios which have included this common.properties file. If you want to use ignores in a particular test scenario, then you can put them in that related scenario.properties file.

In the subsections below, the ignores are explained by showing their effect on a target XML document. This target XML reads as follow:

<Result>
  <RecordID>12</RecordID>
  <FilePath>C:\Users\..\myZipfile.zip</FilePath>
  <File>UEsDBBQAAAAAAABUqlKWlLkWCgAAAAoAAAASAAAAbXlaaXBmaWxlL3Rlc3QudHh0TGFydmEgVGVzdFBLAQIUABQAAAAAAABUqlKWlLkWCgAAAAoAAAASAAAAAAAAAAEAIAAAAAAAAABteVppcGZpbGUvdGVzdC50eHRQSwUGAAAAAAEAAQBAAAAAOgAAAAAA</File>
  <Decimal>12.34</Decimal>
  <Category>ABC</Category>
  <Timestamp>2019-10-02T10:12:43.788+0100</Timestamp>
  <Message>In this record, RecordID='12', RecordID and Timestamp change every time when you run the test</Message>
</Result>

Using ignore

ignoreRegularExpressionKey

This replaces all occurrences of regular expression with IGNORE. By writing

all uppercase letters of the current result and the expected result will be replaced with IGNORE.

ignoreKey

This replaces all matching occurrences of provided key with IGNORE. By writing

all 4 “RecordID” which appeared in the above example will be replaced with IGNORE. In this case, comparing RecordID will still fail, because it won’t replace the content of RecordID.

ignoreContentBetweenKeys

This replace all characters found between key1 and key2 with IGNORE. By writing

content between those two tags will be replaced with IGNORE, so comparing RecordID will always succeed no matter what the value is of it.

And by writing

this will replace the RecordID value in the element <Message> with IGNORE.

ignoreKeysAndContentBetweenKeys

This is similar to ignoreContentBetweenKeys, the only difference is that it replaces all characters found between key1 and key2, including key1 and key2, with IGNORE. Write as

ignoreContentBeforeKey

This replaces everything before provided key has been found with IGNORE. By writing

content before “ABC”, in this case is “<RecordID> 12</RecordID> <Category>”, will be replaced with IGNORE.

ignoreContentAfterKey

The opposite of ignoreContentBeforeKey is ignoreContentAfterKey, this replaces everything after provided key has been found with IGNORE. By writing

it will replace everything after “ABC” with IGNORE.

ignoreCurrentTimeBetweenKeys

This replaces time found between key1 and key2 with IGNORE_CURRENT_TIME, pattern can be null. Write as

Other way of using ignore

Since IAF 7.6 version, it allows ignoring the result of a specific test step by writing step.service.read=ignore. For example, in the scenario.properties file, you write step7.database.Generic.read=ignore to ignore the result of this step.

Using replace

replaceRegularExpressionKeys

This replaces all matches of regular expression (key1) with the value of key2. By writing

all 4 “RecordID” will be replaced by “ID”.

replaceKey / replaceEverywhereKey

replaceKey and replaceEverywhereKey work the same, both replace all matching occurrences of provided key with provided value, write as:

and

Using remove

removeRegularExpressionKey

This replaces all matches of regular expression with “”, write as

all digits will be removed from the result.

removeKeysAndContentBetweenKeys

This removes all characters found between key1 and key2, including key1 and key2. By writing

“<RecordID> 12</RecordID>” will be removed from the result.

removeKey

This removes all matching occurrences of provided key, by writing

all 4 “RecordID” will be removed from the result.

Others

decodeUnzipContentBetweenKeys

This decodes and unzips file content between key1 and key2, if replaceNewlines is true, it will replace all “\r” with “[CARRIAGE RETURN]” and all “\n” with “[LINE FEED]”. In the example, there is an element <File>UEsDB...</File>, it is an encoded zip file named “myZipfile.zip”, which contains a text file “test.txt” with content “Larva Test” written in it. By writing

it will first decode the content and then unzip this zip file to format “<tt:file xmlns:tt=”testtool”><tt:name>myZipfile/test.txt</tt:name><tt:content>Larva Test</tt:content></tt:file>”, and put it in between the 2 keys.

canonicaliseFilePathContentBetweenKeys

This canonicalizes file path content between key1 and key2. In the example, there is an element <FilePath>C:\Users\..\myZipfile.zip</FilePath>, by writing

it replaces “C:\Users..\myZipfile.zip” with the canonical pathname of the file object “C:\myZipfile.zip”.

formatDecimalContentBetweenKeys

This formats decimal content between key1 and key2, the goal of using it is to be able to compare strings by formatting a decimal number to a canonical representation. For an integer, it will be presented as a string of digits, for example, “100” will still be “100”. And for a number which has a decimal fraction, it will be presented as a string, because the decimal precision is not known, for example, “003.0100” will become “3.01”. In the example, there is an element <Decimal>12.34</Decimal>, by writing

it will format this numeric value to <Decimal>12.34</Decimal>, in this case nothing has changed.

Example solution

To make the target XML document at the beginning of this subsection pass the Larva test, you can write the following ignores in your test: