Skip to content

Latest commit

 

History

History
295 lines (186 loc) · 7.97 KB

FMTestAPI.md

File metadata and controls

295 lines (186 loc) · 7.97 KB

Back

FMTest API

All scripts begin with FMT: (colon)
All Custom Functions begine with FMT. (period)

Scripts

FMT:WriteOutputBuffers

Writes the available testing output from $$FMT_Output and $$FMT_OutputSummary into the FMT::Output and FMT::Output_Summary global fields.
Note: FMT::Output and FMT::Output_Summary must be on the layout and writable when this script is called

Parameters {empty}

Returns {JSONObject}

  • success {JSONBoolean} true if the script has run successfully
  • errorCode {JSONNumber} The FileMaker error if exists
  • errorMessage {JSONString} The message if exists

FMT:Reset

Resets all Global variables and fields used by FMTest

Parameters {empty}

Returns {empty}

Custom Functions

Custom Functions make up the 'testing' components. This allows you to write test scripts using as little or as much of FMTest's functions as you like.

These Custom Functions update 3 main Global Variables as well as returning data.

  • $$FMT {JSONObject} All data and test results are stored here in JSON format allowing for intergration with other platforms
  • $$FMT_OutputBuffer {Text} Holds the Output text from FMT custom functions until the script FMT:WriteOutputBuffers is run
  • $$FMT_OutputSummaryBuffer {Text} Holds the Output Summary text from FMT custom functions until the script FMT:WriteOutputBuffers is run

For general use, you don't need to know about them. However the effects on each of these globals is discussed in the Custom Function descriptions below.

More info about the $$FMT JSON structure etc in Under the Hood

FMT.Describe

FMT.Describe( testcase_description )

Place before a set of Assertions that make up a test case.
This should be called before calling Assertions of the current test case

Paramaters

  • testcase_description {Text} Description of the test case you are testing

Returns {JSONObject}

  • description {text} As passed into the function
  • assertions {JSONArray} Results of each Assertion following this Describe. Note: It is empty at this stage

$$FMT
Adds the new test JSONObject to $$FMT.scripts[].tests[]

$$FMT_OutputBuffer
Print the Description

$$FMT_OutputSummaryBuffer
No change

Each of the Assert custom functions below has the following:

Parameters

  • describe_assertion {Text} Describe the thing you are asserting
  • value {Any} The actual value from your script or calculation
  • expected_value {Any} The expected value, or thing to find in thing such as the item to find in a list

Returns {JSONObject}

  • description {Text} As passed into the function
  • result {Boolean} The result of the test
  • failText {Text} Text indicating thing does not have the expected value

$$FMT
Adds the new assertion JSONObject to $$FMT.scripts[].tests[].assertions[]

$$FMT_OutputBuffer
Prints the resulting text from the test

$$FMT_OutputSummaryBuffer
No change

FMT.Assert.Equal

FMT.Assert.Equal ( describe_assertion ; value ; expected_value )

Test that value = expected_value

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.NotEquals

FMT.Assert.NotEquals ( describe_assertion ; value ; expected_value )
Test that value <> expected_value

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.GreaterThan

FMT.Assert.GreaterThan ( describe_assertion ; value ; expected_value )

Test that value > expected_value

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.LessThan

FMT.Assert.LessThan ( describe_assertion ; value ; expected_value )

Test that value < expected_value

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.Empty

FMT.Assert.Empty ( describe_assertion ; value )

Test that value is empty

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.NotEmpty

FMT.Assert.NotEmpty ( describe_assertion ; value )

Test that value is not empty

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.HasJSONKey

FMT.Assert.HasJSONKey ( describe_assertion ; json ; key )

Test that the JSONObject in json has a key named key

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.IsInList

FMT.Assert.IsInList ( describe_assertion ; list ; value )

Test that value is in list

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

FMT.Assert.NotIsInList

FMT.Assert.IsInList ( describe_assertion ; list ; value )

Test that value is not in list

Parameters, Return and and Effects
Assert Parameters, Returns and Effects

Initialisers and Concluders

FMT.InitTestScript

FMT.InitTestScript ()

Paramaters {empty}

Returns {JSONObject}

  • scriptName {JSONObject}
  • tests {JSONArray} An empty Array
  • result {Boolean} The overall result of the script (initially true)
  • assertionCount {JSONNumber} The number of assertions made for this test script (initially 0)
  • assertionPassCount {JSONNumber} The number of passes in this test script (initially 0)
  • assertionfailCount {JSONNumber} The number of fails in this test script (initially 0)

$$FMT
Adds the test script details to $$FMT.scripts[]

$$FMT_OutputBuffer
Prints the TestScript script name

$$FMT_OutputSummaryBuffer
Prints the TestScript script name

FMT.ConcludeTestScript

FMT.ConcludeTestScript ()

Test that value is not in a FileMaker list

Paramaters {empty}

Returns {JSONObject}

  • scriptName {JSONObject}
  • assertions {JSONArray} Results for all test Scenerios per 'FMT.Describe'
  • result {Boolean} The overall result of the script
  • assertionCount {JSONNumber} The number of assertions made for this test script
  • assertionPassCount {JSONNumber} The number of passes in this test script
  • assertionFailCount {JSONNumber} The number of fails in this test script

$$FMT
No change

$$FMT_OutputBuffer
Prints the script summary

$$FMT_OutputSummaryBuffer
Prints the script summary

FMT.InitTestCase

FMT.InitTestCase ()

Paramaters {empty}

Returns {JSONObject}
The new $$FMT JSONObject

$$FMT
Adds the testcase name

$$FMT_OutputBuffer
Prints the TestCase script name

$$FMT_OutputSummaryBuffer
Prints the TestCase script name

FMT.ConcludeTestCase

FMT.ConcludeTestCase ()

Set a variable using this Custom Function after all Test Scripts have been run

Paramaters {empty}

Returns {JSONObject}
The entire $$FMT JSONObject

$$FMT
No change

$$FMT_OutputBuffer
Prints conclusion info text

$$FMT_OutputSummaryBuffer
Prints conclusion info text

Helpers

FMT.StartTimer

FMT.StartTimer ("MyTimer")

Starts a timer with the given name

Paramaters

  • identifier {text} The name of the timer. Default: The script name

Returns {number}
The UTC milliseconds start time

$$FMT
Adds 'identifierStartTime' to the current script JSONObject

$$FMT_OutputBuffer
Prints "identfier: Timer Started"

$$FMT_OutputSummaryBuffer
no change

FMT.GetTimer

FMT.GetTimer ("MyTimer")

Get's the time in Milliseconds since the timer started

Paramaters

  • identifier {text} The name of the timer. Default: The script name

Returns {number}
The milliseconds since the timer started

$$FMT
Adds 'identifierEndTime' {JSONNumber} and 'identifierTotalTime' {JSONNumber} to the current script JSONObject
If GetTimer is called more than once for the same identifier in the same test script it overwrites these values

$$FMT_OutputBuffer
Prints "identfier: xxxx ms"

$$FMT_OutputSummaryBuffer
no change