AddStatistic

Top  Previous  Next

 

You can add custom statistics to the summary page for sorting. Best if used in After Test script after the statistic has been calculated.

Adds a new statistic which will show up in the test summary list and can be sorted there.

 

 

Syntax

 

AddStatistic( statisticName, value, [decimal places], [type] )

 

Parameters

statisticName

 

the string name of the statistic to be added

value

 

the value of that statistic

decimal places

 

the optional number of decimal places for display of float numbers. Default is 2 if left out.

type

 

the optional type, such as "integer", "float", "decimal", "currency", "date" or "string". If type is used, decimal places is still optional. Float is default, although if value is a string the String type is assumed.

 

 

 

 

 

Optional Types

 

"Integer"                        Prints as an integer, truncated.

"Float"                        Prints as a floating point number, default.

"Decimal"                        Prints as a decimal, multiplied by 100 and a % added.

"Currency"                        Prints as a comma delimited number with currency symbol prefixed.

"Date"                        Prints as a date string YYYY-MM-DD.

"String"                        Prints as a string. Must be a string, cannot be a number.

 

Example

 

test.AddStatistic( "Adjusted MAR", 2.12345 )                                        ' Output is 2.12

test.AddStatistic( "My Custom Stat", 2.12345, 3 )                                ' Output is 2.123

test.AddStatistic( "My Custom Stat", 2.12345, "Integer" )                ' Output is 2

test.AddStatistic( "The Best Market", "Gold", "String" )                ' Output is "Gold"

test.AddStatistic( "The Best Market", "Gold" )                                ' Output is "Gold"

test.AddStatistic( "Return", 2.12345, "Percent" )                                ' Output is "2.12%"

test.AddStatistic( "Return", 2.12345, 0, "Percent" )                        ' Output is "2%"

test.AddStatistic( "Worst Date", 20010521, "Date" )                        ' Output is "2001-05-21"

test.AddStatistic( "Highest Value", 500000, "Currency" )                ' Output is "$500,000"