Rules
Sections can define rules for different behaviors in case of errors. The basic rule definition is as follows:
section[' <section_name> | reRun: <reRunCount> , failOptions: <[ exitAndFailed , continueAndNoFailed, continueAndFailed]> '] , jump: <sente_name> '
Re-Run on Error
This feature ensures that if a section fails, it will be rerun automatically.
section[' <section_name> | reRun: <reRunCount> ']
default value: 0
max value: 3
In the example below, if the section named "Red" fails, it will be retried up to 2 additional times, as specified by reRun: 2
, until it succeeds.
TEST FLOW
*************/
section['Red | reRun: 2'] = async () => {
/*
Write your test codes here.
*/
}
section['Blue' ] = async () => {
/*
Write your test codes here.
*/
}
Options On Error
If a section fails, we can define how it should behave. Three behavior methods have been defined: exitAndFailed
, continueAndNoFailed
, and continueAndFailed
.
section[' <section_name> | failOptions: <option> ']
default value: exitAndFailed
exitAndFailed
If the section fails, test will terminate and fail.
continueAndNoFailed
If the section fails, continue and run the next sections.
In the example below, even if the section named "Red" fails, the section named "Blue" will be executed. The success/failure status of the test will be determined by the Blue section. The error in the Red section is ignored.
TEST FLOW
*************/
section['Red | failOptions: continueAndNoFailed'] = async () => {
/*
Write your test codes here.
*/
}
section['Blue' ] = async () => {
/*
Write your test codes here.
*/
}
continueAndFailed
In the example below, even if the section named "Red" fails, the section named "Blue" will be executed. Even if the Blue section is successful, the Test will be considered failed because the Red section was unsuccessful.
TEST FLOW
*************/
section['Red | failOptions: continueAndFailed'] = async () => {
/*
Write your test codes here.
*/
}
section['Blue' ] = async () => {
/*
Write your test codes here.
*/
}
Jump On Error
It allows jumping from one section to another in case of error. If we have a test with multiple sections, if a certain section fails, the sequential execution of the sections can be stopped and the desired section can be run. (Important: Jump does not work in the last section)
section[' <section_name> | jump: <section_name> ']
In the example below, if the Red Section fails, it will jump over the Yellow section and begin executing the Blue section.
TEST FLOW
*************/
section['Black | '] = async () => {
/*
Write your test codes here
*/
}
section['Red | jump: Blue'] = async () => {
/*
Write your test codes here
*/
}
section['Yellow'] = async () => {
/*
Write your test codes here
*/
}
section['Blue'] = async () => {
/*
Write your test codes here
*/
}
section['Green'] = async () => {
/*
Write your test codes here
*/
}
Multiple Rule Usage
In the example below:
If the Black section fails, it will run once more. Regardless of success or failure, the Red section will still execute.
The Red section will execute; if successful, the Yellow section will run. If it fails, it will jump to the Blue section.
If the Blue section fails, it will rerun two more times. If it still fails, the test will stop, and the test status will be considered failed. If the Blue section is successful, the Green section will execute.
TEST FLOW
*************/
section['Black | reRun:1, failOptions: continueAndNoFailed '] = async () => {
/*
Write your test codes here
*/
}
section['Red | jump: Blue, failOptions: continueAndNoFailed '] = async () => {
/*
Write your test codes here
*/
}
section['Yellow'] = async () => {
/*
Write your test codes here
*/
}
section['Blue | reRun: 2, jump: Blue, failOptions: continueAndNoFailed'] = async () => {
/*
Write your test codes here
*/
}
section['Green'] = async () => {
/*
Write your test codes here
*/
}
Last updated