This article explains how to assemble a simple end-to-end test using common test suite items (setup/teardown regions, test cases, module groups, and smart folders).
To follow along with this tutorial, download the sample solution from the link below.
Theme: Build a test
Time: 15 minutes
Install the sample solution
- Unzip to any folder on your computer.
-
Start Ranorex Studio and open the solution file
RxDatabase.rxsln
Define the test
Define the test's purpose before you start building. Keep it simple, your test will add one entry to a database and then validate that it was added.
The AUT is the Ranorex Demo Application. The required steps are as follows:
- Start the Ranorex Demo Application.
- Click the Test database tab.
- Enter the first name in the First name field.
- Enter the last name in the Last name field.
- Select the department from the Department drop-down.
- Enter the age in the Age field.
- Select a gender from the Gender box.
- Click Add Entry.
- Validate that Number of entries changed from 0 to 1.
- Exit the Ranorex Demo Application.
Review the recording modules
The sample solution already contains the required recording modules.
The modules are organized in two folders.
- Application functions: Modules that control the AUT (for example, starting and exiting the Ranorex Demo Application).
- Database functions: Modules related to adding an entry to the database.
The modules in these folders are quite specific, as you can see from their names. They each contain only the actions necessary for an individual step in our test definition. Small, focused modules are easier to reuse and give you more flexibility when assembling tests.
Assemble the test
Everything is ready, so let’s get to business and start building our test. There is one test suite in the project, RxDatabase.rxtst. It should already be open. If it is not, double-click the file in the project view.
Add a setup region
In the test suite view, the test suite is mostly empty except for a single default test case.
Starting the AUT is step 1 in the test definition, so add it first. This is a great fit for a global setup region because the test cannot proceed without the AUT being open.
To add a global setup region:
In the test suite view, right-click the test suite and click Add setup.
-
From the Module browser, drag the module StartAUT to the setup region.
Add the database test
Steps 3–9 are the core of the test (entering data, adding the entry, and validating it). Put these steps into a dedicated test case. Use the existing test case, but rename it first:
Select the test case and press
F2.Rename it to SimpleDatabaseTest and press
Enter.
Now add the required modules to SimpleDatabaseTest (in test definition order):
- AddEntry
- InsertAge
- InsertName
- SelectDepartment
- SelectGender
- ValidateEntries
Now, you can fill the test case with the required modules. These are, in test definition order: InsertName, SelectDepartment, InsertAge, SelectGender, AddEntry, and ValidateEntries. You can add the first four modules in any order you like, but AddEntry must be second to last, and ValidateEntries must be last.
To add the modules:
From the module browser, drag the modules to the test case:
- You can add them individually or select several modules at once using
Ctrl+ Click. - If you misplace a module in the test suite view, simply drag it to its correct place.
Create a module group
The modules InsertAge, InsertName, SelectDepartment, and SelectGender are all part of the same process: defining the data that will be added to the database, in other words, inserting a person. This is why it makes sense to organize them in a module group. This way, you won’t have to add all four modules over and over again when you create more test cases where this process is needed.
To create a module group:
- In the Test suite view, select the four modules using
Ctrl+ Click orShift+ Click. - Right-click the modules, and click Group selected modules.
- The new module group opens in the module group view.
- Rename the module group to InsertPerson and close it.
- The test case now contains the InsertPerson module group, and it also appears in the Module browser for reuse.
Add a smart folder
As tests grow larger and more complex, it can become difficult to manage the test suite.
Smart folders are a useful structuring item to overcome this issue. Instead of filling a test case with 50 modules that all logically belong to the same test, add smart folders to the test case and organize the modules in them. Smart folders also make it easy to exclude particular parts of a test case from being run during test execution. This is exactly what we use a smart folder for in our example. You may not always want the validation to be carried out, so it will have its own smart folder.
To add ValidateEntries to a smart folder:
- Right-click the test case SimpleDatabaseTest and click Add > New smart folder.
- Drag ValidateEntries into the new smart folder.
- Rename the smart folder to Validation.
Add a teardown region
The last step is exiting the Ranorex Demo Application. This is a perfect example of a step that should be in a global teardown region because, after it, no other test actions can be performed. The system is restored to its state before the test. Normally, this would also include deleting all entries made, but the database doesn’t save any entries when exiting, so you don’t need to include this action.
To add a teardown region:
- In the Test Suite view, right-click the test suite and select Add teardown.
- From the Module browser, drag ExitAUT to the teardown region.
Run the test
You’ve built a complete test in the test suite. To run it, click the large RUN button in the test suite view.
For details and advanced options (run configurations, reporting, error behavior, and running via the Ranorex Test Suite Runner), see Execute a test suite.