Skip to main content

Assert Preconditions

Assert preconditions are a set of conditions, which must be fulfilled before executing asserts for a participant. Preconditions not only give more flexibility and control over the assertion process but also provide advanced monitoring capabilities, making results more accurate and easier to analyze. Adding preconditions is optional for assert configuration and can be omitted, if not needed.

Use of preconditions

Assert preconditions can be configured while creating or editing a test in the assert creation view. To use preconditions add them from the predefined list to an existing assert. The following properties can be used to define assert preconditions:

Precondition chaining

To apply multiple preconditions to the same asserts, they can be chained. By default, multiple preconditions set for a single assert are chained using logical AND operator. In other words, an assert will be executed only if all set preconditions were fulfilled.

For example, if assert should be executed only when participant location is not equal to ap-east-1 AND browser is the latest version of Mozilla Firefox:

PathPreconditionOperatorExpected
machine/cpu/maxbrowser == firefoxLatest location != ap-east-1>20

Chaining with OR
To implement chaining with logical OR operator, it is necessary to create duplicate asserts with appropriate preconditions.
For example, if assert should be executed only when participant location is not ap-east-1 OR browser is the latest version of Mozilla Firefox:

PathPreconditionOperatorExpected
machine/cpu/maxbrowser == firefoxLatest>20
machine/cpu/maxlocation != ap-east-1>20
info

Pay attention when chaining multiple preconditions from the same property field, e.g., Browser. In many cases such preconditions can be contradicting.

For example, chaining two preconditions with browser properties and using AND operator will result in skipped assert.

PathPreconditionOperatorExpected
machine/cpu/maxbrowser == firefoxLatest browser == chrome79>20