Preparations for data-driven testing | Ranorex
Help CenterUser GuideRanorex Studio advanced

Preparations for data-driven testing

The method of data-driven testing is not complicated. But it needs some defined and careful preparations. This section is to introduce these preparations. Referring to the chapter introduction, a test case or smart folder is needed as the basis for data-driven testing. Together with a set of test-data, these represent the toolkit for data-driven testing. Therefore, the test settings are defined and explained in this section where the set of test data is introduced right afterward.

In this chapter

    Test example definition

    Testing a database is a common and well-suited example for applying data-driven testing. Therefore, a small database which is implemented by the Ranorex demo application will be used to explain the principles of data-driven testing.

    Test database in Ranorex demo application

    Test database in Ranorex demo application

    The working environment of the test database is activated by clicking the corresponding register tab

    Principle of inserting data into the test database

    Principle of inserting data into the test database

    Inserting person data into the database form and clicking Add entry adds persons to a list
    Test example with 8 persons in list

    Test example with 8 persons in list

    During the test example, 8 persons are added to the database one after another
    After each entry adding, the database counter is verified if it calculates correctly

    Prepared sample solution

    The explanation of data-driven testing is based on a prepared illustrating sample solution which will be developed further within this chapter. The download link of this solution can be found in the introduction to the chapter ⇢ Data-driven testing.

    Sample solution working environment

    Sample solution working environment

    Project file view with recording modules structured in folders
    Prepared test suite with a ready-to-run database test scenario

    Definition of recorder variables

    The definition of variables initiates the design of a data-driven test. This section shows how to replace the constant text values for name and age of a person by variables which then can be filled with corresponding test data.

    Examples for recorder variables

    Examples for recorder variables

    Important to know:

    • In our example, the constant text values of the first name, the last name, and the age are to be replaced by variables
    • Variables in Ranorex always start with a preceding ‘$‘ followed by the variable name

    Action(s):

    Adding a new text variable

    Adding a new text variable

    Open the drop-down list near a constant value and click As new variable…
    Assign the variable a meaningful name and confirm with OK
    See the green printed variable name replacing the former constant value

    Defining all recorder variables

    Definition of three recorder variables in test example

    Definition of three recorder variables in test example

    Variable $txtFirstName replacing the constant value ‘John’ for the first name
    Variable $txtLastName replacing the constant value ‘Public’ for the last name
    Variable $intAge replacing the constant value ’48’ for the age

    Further reading

    The concept of variables & parameter, especially the definition of recorder variables are introduced and explained in detail in > Ranorex Studio advanced > Variables & parameter > 
    ⇢ Recorder variables.

    Making list items variable

    Any UI-element to interact other than a text entry field which is variable can be automated by repository variables. Menu items or list items are two common examples for such UI-elements. The herein introduced concept of repository variable is applied to list items.

    Making list items variable

    Making list items variable

    Important to know:

    • The constant choice of ‘Project Management’ as department selection is to be replaced by a variable
    • All list items are contained within a drop-down list

    Action(s):

    Making a repository item variable...

    Making a repository item variable…

    Select the action item which interacts with the target UI-element (i.e. the click-action which selects the corresponding list item)
    Open the context menu and click Make repository item variable…

    Assigning a repository variable

    Assigning a repository variable

    Assign the variable a meaningful name and confirm with OK
    Click APPLY to activate the repository variable definition

    Result(s):

    Defined list item variabel

    Defined list item variabel

    Repository variable $lstDepartment to replace constant department selection

    Further reading

    The definition and specification of repository variables are introduced and explained in detail in > Ranorex Studio advanced > Variables & parameter > ⇢ Repository variables

    Making radio buttons variable

    The current test example outlines two radio buttons with the optional selection of gender. This section shows how to make the radio button selection variable by means of repository variables.

    Making radio button selection variable

    Making radio button selection variable

    Important to know:

    • The solution is based upon the principle of repository variables
    • The conditional selection works with an attribute which distinguishes between the two radio buttons
    ControlText attribute making radio buttons variable

    ControlText attribute making radio buttons variable

    The test data of the current example distinguishes between male and female person by a data item containing ‘Male’ and ‘Female’ as value. Therefore, the radio button attribute ControlText is used for distinguishing between the selections. 

    Male radio button selection with ControlText attribute
    Female radio button selection with ControlText attribute

    tipp icon

    Hint

    To make a data-driven testing robust against localization (other languages), it is recommended to use other attributes, such as ControlName, or others.

    Action(s):

    Making a repository item variable...

    Making a repository item variable…

    Select the action item which represents the radio button click action and open the context menu
    Click Make repository item variable…

    Applying repository variable

    Applying repository variable

    Assign the variable a meaningful name and confirm with OK

    Click APPLY to activate the repository variable

    Result(s):

    Radio button selection made variable

    Radio button selection made variable

    Repository item representing gender radio button selection with variabel $selGender

    Further reading

    The definition and specification of repository variables, especially making radio buttons variable, are introduced and explained in detail in > Ranorex Studio advanced > Variables & parameter > ⇢ Repository variables.

    Making test validation variable

    As specified in the test definition the test validation verifies if the database counter calculates the number of data entries correctly after each insertion. This section shows how to make a test validation variable and ready for data-driven testing.

    Example for test validation variables

    Example for test validation variables

    Important to know:

    • The database size is displayed in the upper-right corner of the database list in the demo application
    • The corresponding counter updates after a change of database size
    • The database counter is to be replaced by a variable

    Action(s):

    Definition of validation variable

    Definition of validation variable

    Select the validation action and open the drop-down list of the match value. Click As new variable…
    Assign the variable a meaningful name and confirm with OK
    See the green printed variable name $intDBEntries in the action list

    Further reading

    Validation variables (i.e. replacing match values by variable) are introduced and explained in detail in > Ranorex Studio advanced > Variables & parameter > ⇢ Validation variables.

    Overview of prepared variables

    When preparing a test case for data-driven testing by means of variable definitions, Ranorex Studio always informs you about the status of the variable bindings.

    Defined, but unbound example variables

    Defined, but unbound example variables

    The test suite view displays the defined, but yet unbound variables