Conditions and rules let you control when a test container runs. They evaluate data from an assigned data source or parameter, and then run (or skip) a test container based on whether your rule matches.
To follow along with the instructions in this chapter, download the sample solution file from the link below.
Theme: Conditions
Time: 15 minutes
Install the sample solution
- Unzip to any folder on your computer.
-
Start Ranorex Studio and open the solution file
RxDatabase.rxsln
Test scenario
For this example, use the data-driven test from the previous steps in this workflow. This time, ypu want to insert only female staff members into the database of the Ranorex Studio Demo Application.
In summary:
- Normally, 8 staff members are inserted into the database.
- You want to modify the test case so that it enters only female staff members into the database.
- You want to accomplish this with a condition.
Add a condition
Keep these constraints in mind:
- You can add a condition to test cases or smart folders only.
- You can define one condition per test container.
- A condition contains one or more rules.
The workflow is the same for test cases and smart folders.
To add a condition:
- In the test suite, right-click the test case or smart folder where you want to add the condition.
- Click Condition…
- In the Condition tab, click Add rule.
-
- The Condition tab of the test container properties dialog.
- The inactive condition has no rules defined below it yet.
Define rules
Conditions are defined by rules. You can add up to 10 rules to a condition. Each rule checks whether a data source or parameter value is equal or not equal to a control value.
Define a rule from left to right, then click OK.
- Data source/Parameter: Select whether the value you want to check is in a data source or a parameter.
- Specific data source/parameter: Select the specific data source or whether it is a local/global parameter that contains the value.
- Column/row: Select the column (data sources) or the row (parameters) that contains the value.
- Operator: Select whether the value you want to check must be equal or not equal to the control value.
- Control value: Select a possible control value from the data source/parameter.
Result
If you defined the rule just as above, you now have a condition with one complete rule. In the test suite view, this is indicated as follows:
- Conditional test case.
- Indicator showing that the test case has an active, defined condition.
Condition settings
In the condition dialog, you can also configure:
- Activation checkbox: Quickly switch between active/inactive conditions. Do not delete any defined rules.
- Condition operator: Sets when the condition is met and the test container is run.
- Incomplete rule indicator: Appears wherever a rule is missing information.
- Rule completeness indicator: Shows whether the rule is complete or incomplete.
Condition status
Depending on their completeness and activation status, conditions are indicated by three different symbols in the test suite view:
- Active condition with one or more complete rules.
- Active condition with one or more incomplete rules.
- Inactive condition with one or more complete or incomplete rules.
Run the test
The condition is complete and ready to use. Run the test from the test suite view as usual.
Expected results
In the Demo Application, the database shows only female staff members inserted.
In the report, iterations where the condition is not met are marked as blocked.
(Image: report showing blocked iterations)
You can download the completed sample solution with all the steps in this chapter carried out and ready to run:
Theme: Conditions
Time: 15 minutes
Install the sample solution
- Unzip to any folder on your computer.
-
Start Ranorex Studio and open the solution file
RxDatabase.rxsln