Notification Rules
Testomat.io allows sending notifications for finished runs:
- Send brief reports to stakeholders
- Notify team members of failed tests
- Configure on which condition notification should be sent
Testomat.io has powerful rule engine which can be used to define on which conditions a notification should be sent. You can have multiple notification types with different notification channels in use for a single project.
Basic Rules
Section titled “Basic Rules”There is a basic and advanced rules engine.
Inside Basic rules you can define simple conditions on which notifications should be sent:
- Runs with title.
- Runs of RunGroup with title.
- Run Type.
- Run Status.
For instance, here is the rule for all manual runs with “Release” word in title to be reported:
Advanced Rules
Section titled “Advanced Rules”The advanced rules engine allows writing conditions in a special expression language similar to Ruby or JavaScript.
This is the same rule we defined previously in Basic mode written in the format of Advanced mode. A notification will be sent for all manual runs that contain the word “Release”:
manual and contains(run, "Release")
A complete list of allowed variables:
automated
- boolean. True if a run is automatedmanual
- boolean. True if a run is manualhas_failed
- boolean. True if a run has failedhas_passed
- boolean. True if a run has passedwas_terminated
- boolean. True if a run was terminatedrun
- string. Title of a runrungroup
- title. Title of rungroup a run belongs tostatus
- string. Status of run, ‘passed’ or ‘failed’ as a string.started_at
- datetime. Time when the run was started.finished_at
- datetime. Time when the run was finishedpassed_tests
- collection. A list of all passed tests in a run.failed_tests
- collection. A list of all failed tests in a run.skipped_tests
- collection. A list of all skipped tests in a run.
An expression should return a boolean value. To deal with types other than boolean functions and methods can be used:
String
String values can be checked with equal ==
or not equal !=
operators. Also there is contains
function which checks inclusion of a string in another string:
contains(run, "New")
Collection
Collections contain an array of objects.
Use .size
to check for the size of items in the collection. For instance, this rule is activated when a number of failed tests is more than 10.
failed_tests.size > 10
Collection of tests can be filtered. Tests in the collection have following properties:
test['title']
- title of a testtest['suite']
- title of a suite of a testtest['id']
- id of a testtest['suite_id']
- id of a suitetest['status']
- status of a test in collection
For instance, this is how to check if a collection of failed tests contains at least one test with @important
tag in its name:
failed_tests.filter(test, contains(test["title"], "@important")).size > 0
DateTime
started_at
and finished_at
variables are of datetime type. They have properties from Date and DateTime classes of Ruby that can be used in expressions. Most used ones are:
hour
minute
day
wday
month
year
- etc
For instance, this is how notification can be enabled for reports finished in non-business time:
(finished_at.hour > 18 or finished_at.hour < 9)
Examples
Section titled “Examples”Notify when tests are failing on CI:
To match tests executed on CI specify a Run title with “[CI]” prefix to identify that these tests were executed on CI:
TESTOMATIO_TITLE="[CI] Automated Tests"
Then write a notification rule that will check only for failing runs with “[CI]” in their title:
contains(run, "[CI]") and has_failed
Notify when automated tests are terminated:
automated and was_terminated
Examples for Runs Notifications
Section titled “Examples for Runs Notifications”Notify when a Run has failed between 10 PM and 9 AM:
has_failed and (finished_at.hour > 22 or finished_at.hour < 9)
Notify when an automated Run has failed on alpha environment:
automated and has_failed and contains (env, "alpha”)
Notify when a Run that contains at least one test with the word “autocomplete” in the title has passed:
has_passed and passed_tests.filter(test, contains(test["title"], "autocomplete")).size > 0
For example:
And Run that matches this Notification rule:
Run Group Notifications
Section titled “Run Group Notifications”To configure Notification Rule for Run Group you need:
- Select rungroup for Notification rule context
- Add your Rule Expression, for example, you can use
rungroup_finished
variable if you want to get notification when all Run report inside the group are finished.
Rules for Run Group Notifications
Section titled “Rules for Run Group Notifications”The rules engine allows writing conditions in a special expression language similar to Ruby or JavaScript.
A list of allowed variables:
title
- string. Title of a rungrouprungroup_finished
- boolean. True if all runs completed => True if rungroup contains only finished runs.runs
- collection. A list of all runs inside a rungroupfinished_runs
- collection. A list of finished (passed or failed) runs inside a rungroupongoing_runs
- collection. A list of pending runs (scheduled, in progress) runs inside a rungroupfailed_runs
- collection. A list of failed runs inside a rungroup
Examples for Run Groups Notifications
Section titled “Examples for Run Groups Notifications”Notify when all runs within one Run Group (Run Group include more than 1 run) are finished:
(runs.size > 1) and rungroup_finished
Notify when there is at least one run in the finished_runs
collection whose finished_at
timestamp is older than 100 seconds ago:
finished_runs.filter(run, run['finished_at'] < 100.seconds_ago).size > 0
Notify when there are no currently ongoing runs in the run Group (means all runs are finished):
ongoing_runs.filter(run, run['created_at'] <= 0.seconds_ago).size == 0
Notify when next rules are met:
- the title of the Run Group contains the substring ‘str-’ and
- all runs within this Run Group are finished and
- at least one of the runs within this Run Group has a title that contains the exact string ‘islast: true’
contains(title, "str-") and rungroup_finished and (runs.select(run, contains(run["title"], "islast: true")).size > 0)
For example:
And Run Group that matches this Notification rule: