Structured Log File (.slf) Specification



Introduction

The Structured Log File (.slf) file format is used to store the Structured Log Testing data to a file. The log data by defalit can be loaded into a Structured Log Testing TestDriver application as a TestPointScript. TestPointScript are the assertion logic for any code run by a TestDriver application.

For advanced visual applications that are generating TestPointScript .slf files there is a set of assertion logic operators that can be used. These operators allow for TestPoint assertions to check wide range of data points. Think of writing a test script that tests a value is between 10 and 20 or 20% of the previous TestPoint value. You might say this is too much logic in the test script it self, but I point you to the discussion on Structured Log Testing approach to testing.

File Structure

The file is made up of line return delimited JSON string messages. Each line is considered to be one TestPoint. The first line must contain a special JSON string describing the file and include the following properties:

First Line JSON properties

  • name - The display name of the .slf file
  • identifier - A unique string to distinction similarly named files
  • description - A short description of the test script

Here is a sample Structured Log File (.slf) with its proper header line and data:

1
2
3
{"identifier":"promo1","description":"Checking promotion codes.","name":"Promo1"}
{"tpname":"originalPrice","tpcat":"classes.Discounter","tpuid":"ab5fc99073b7134935724dec11995611","tpdesc":"","price":{"tpop":"greaterThan","params":[0],"tptype":"hamcrest"}}
{"tpcat":"classes.Discounter","tpdesc":"","tpuid":"ab5fc99073b7134935724dec11995611","price":{"tpop":"minus","params":[{"params":[{"tpuid":"ab5fc99073b7134935724dec11995611","tpname":"originalPrice","tpkey":"price"}],"tpop":"linked","tptype":"slt"},10],"tptype":"slt"},"tpname":"price"}


Assertion Logic

Each TestPoint that wants to use Structured Log Testing assertion logic must define the logic as an object in the form:

1
2
3
4
5
6
7
8
9
10
11
12
var tpLogic:Object = new Object();
tpLogic.tptype = "slt"; // The type of logic
tpLogic.tpop = "minus"; // The operator or logic name
tpLogic.params = [100, 10]; // The parameters required by the operator
// Then to save it to the (.slf) format just JSON the whole TestPoint value
var obj:Object = new Object();
obj.tpname = "price";
obj.tpcat = "classes.Discounter";
obj.tpdesc = "";
obj.tpuid = "123"; // Some unique value to use with tpname for unique look up have duplicate TestPoint in the same script
obj.price = tpLogic;
var slfFormat:String = (new JSON()).encode(obj);

No in the previous example the “minus” operator is not doing much since 100 - 10 = 90 and we colid have just put that into the script to check. But the cool thing about the assertion logic format is you can next the objects to perform complex logic chains. Here is the code from the example above but with one with the “minus” operator’s first parameter coming from a previous TestPoint:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var bLogic:Object = new Object();
bLogic.tptype = "slt";
bLogic.tpop = "linked";
bLogic.params = new Array();
bLogic.params.push({tptype:"slt",tpop:"linked",params:new Array()});
bLogic.params[0].params.push({tpname:"originalPrice",tpuid:"345",tpkey:"price"});
var tpLogic:Object = new Object();
tpLogic.tptype = "slt"; // The type of logic
tpLogic.tpop = "minus"; // The operator or logic name
tpLogic.params = [bLogic, 10]; // The parameters required by the operator
// Then to save it to the (.slf) format just JSON the whole TestPoint value
var obj:Object = new Object();
obj.tpname = "price";
obj.tpcat = "classes.Discounter";
obj.tpdesc = "";
obj.tpuid = "123"; // Some unique value to use with tpname for unique look up have duplicate TestPoint in the same script
obj.price = tpLogic;
var slfFormat:String = (new JSON()).encode(obj);

The “linked” assertion logic operator retrieves the value from previous data that is being asserted. The look up for the asserted data is done by looking through the current assertions available comparable data that matches the “tpname”, “tpuid”, and then specific to the “tpkey” TestPoint name value pair. This assertion logic when running in a TestDriver application tells this TestPoint to find the “originalPrice” TestPoint data and then minus 10 from it and compare that with the value for the “price” asserted data.

I have explained how to do this by code above but in the end the goal is to have tooling handle the logic in a simple and visual .slf test script generating application.

Assertion Logic Table

Type: slt

  • minus (param1:Number, param2:Number): Returns (param1 - param2)
    • param1: A Number
    • param2: A Number
  • linked (param1:{tpname,tpuid,tpkey}): Returns value of previous asserted data defined by the param1 attributes.
    • param1.tpname: The name of the previous assertion TestPoint
    • param1.tpuid: Used with tpname to identifier an unique previous assertion TestPoint
    • param1.tpkey: The TestPoint name value pair to plil the value from.

Type: hamcrest

  • greaterThan (param1:Number): Returns (param1 > comparingTestPoint)
    • param1: A Number
  • lessThan (param1:Number): Returns (param1 < comparingTestPoint)
    • param1: A Number

More to come….


SetPageWidth