One of the major challenges with distribution testing is data-driven tests. All tests that are running simultaneously should be able to access the data.
In a few scenarios however, you cannot allow more than one test to access the same data. With data sets offered by HCL OneTest UI (HOT UI), you now have an easier way of tackling this challenge while running distributed tests.
The following terms are used in this post:
- Data sets provide tests with variable data during a run which can be created from scratch or by importing data from a comma-separated-value (CSV) file. For details, see Dataset overview.
- Compound tests help you organize smaller tests into scenarios that can then be run end-to-end. When you run a compound test, each test added to it is invoked in the sequence defined. For details, see Compound tests.
Creating Data sets
Let’s consider a scenario that typically happens in an e-Commerce website. A user logs in, adds products to the cart, and places an order. Thus, the following steps make a case for automated tests:
- login: logging in to the e-Commerce website
- add to cart: selecting and adding products to the cart
- place order: placing an order after confirming the product details
To accelerate testing, you plan to run all the three tests on all the supported browsers in parallel. The application however would not allow for three simultaneous sessions with same user login. Therefore, each run should use a different combination of user ID and password whereas for testing the “place order” step, you can choose the same or different product name.
For the scenario described above, create the following datasets in HCL HOTUI with the required row data:
- DS_Login: stores user login details under two columns – user id, password
- Dataset- DS_Login
— DS_Product: stores product details under three columns – product name, id, seller
- Dataset- DS_Product
Associate DS_Login dataset with the login test and associate input values in the test with the dataset columns. Similarly, associate DS_Product dataset with the addToCart test and associate input values with the respective dataset columns. For details, see Associating a test value with a dataset column.
Creating Compound Tests
To run all the three tests together as a scenario, create a compound test called TC_PlaceOrder in HCL OneTest and add the three tests in the expected order of execution. Insert a loop within the compound test and move the addToCart test into it. This is required to fetch the values (in this case, the product details) from the rows of a corresponding dataset during execution.
- Compound Test
When you run the compound test called TC_PlaceOrder, the login test runs first to log in to the application and then the addToCart test adds products to the cart. The number of products added to the cart is equal to the iteration count specified in the loop. Lastly, the placeOrder test places an order for the products added to the cart.
Distributing Tests
To execute the test scenario on multiple browsers simultaneously, create an AFT test suite called Distribute_TC_PlaceOrder.
- AFT Test suite
When you run the AFT test suite called Distribute_TC_PlaceOrder, the TC_PlaceOrder test runs in Chrome and Firefox in parallel, but tests that are part of the compound test TC_PlaceOrder run sequentially.
At each step of execution in different browsers, the login test fetches the required login details from the different rows of the DS_Login dataset. This way, single user login session is ensured for each parallel test run. After the login test is complete, the addToCart test runs in a loop (for the specified number of times) and simultaneously on different browsers. Each execution of the addToCart test accesses the DS_Productdataset, as if it is a single test accessing the dataset and adds products to the cart.
In summary, HOTUI facilitates parallel test execution by enabling simultaneous access to data while restricting it, wherever needed.
Learn how you can accelerate testing at reduced costs.
Start a Conversation with Us
We’re here to help you find the right solutions and support you in achieving your business goals.