Test Data Generation: Creating the Perfect Symphony

test-data-generation

Introduction

You attend a fabulous concert, imagine one of the world-class opera houses. The performance is outstanding. This is what you would expect, and does it come naturally, or is it taken for granted? By no means! Engineering, rehearsals, precision, talent, and dedication are a few factors that add to the impression of grandeur.

Serving as an analogy to test automation, note that any orchestra such as the concerto grosso requires an orchestra conductor. The role serves as the test automation framework guiding through the various test sets (songs or pieces). The conductor follows the sheet music (test cases) and directs different sections of the orchestra (software components) to play their parts. Each instrument (unit) contributes to the whole concert and is required to perform at the right time.

Test data generation acts as the composer, creating the necessary rhythms and musical notes (test data), which completes the music sheet (test cases). Thorough testing is key to achieving a captivating performance with diverse sounds, accentuations, and harmonies, completing a composer’s creative imagination. Regarding software engineering and automation projects, this equals the range of scenarios that may occur, covering various combinations of input values, boundary conditions, and edge cases. Test data generation systematically generates diverse and appropriate test data that align with the test cases. Hence, professionals in the field of test automation can orchestrate comprehensive and effective tests.

The concert concludes, the curtains are closing. Standing ovation! The cheers demand an encore (let us assume that encores aren't frowned upon at this illustrated venue). The orchestra takes to the stage again, under thunderous applause. But with slightly less confidence. Their next and final song (or piece) is less rehearsed, and contains difficult passages. Should this piece be performed live? Should a partially or even untested project be published to your production environment?

Benefits of test data generation

One of the key areas of improvement and need for action in RPA and intelligent automation projects is testing and the proper release of processes, as also identified by a recently conducted study in the region IDG Intelligent Automation 2023 (DACH). This particular need for action came in second behind process adjustments and process development.

Regarding test data generation UiPath empowers various roles such as test engineers and developers with two significant features: the test data activities within the UiPath.Testing.Activities Package in UiPath Studio and Auto-generated Test Data (see further below). Consequently, professionals can benefit greatly in the following areas:

  • Efficiency and time saving : test data generation significantly reduces the time and effort required to create and manage test data. Manual test data creation can be a time-consuming process, especially when dealing with large datasets.

  • Increased test coverage: a wide range of test scenarios can be addressed, covering various combinations of input data, conditions, and cases. Different aspects of the solution are thoroughly evaluated.

  • Data accuracy and consistency: whereas manual test data creation is prone to errors and inconsistencies, an automated approach employs systematic algorithms to generate accurate and consistent datasets based on defined rules. If required, complete randomness can be achieved by generating new test data at runtime or by selecting random records within the dataset.

  • Scalability: automated test data generation allows professionals to generate large volumes of data quickly, and can easily generate additional rows and records at their leisure. This allows to simulate real-world scenarios with diverse ranges of data or instances, uncovering bottlenecks and providing the system can handle varying loads and volumes.

  • Data Privacy and security: in this area, automated test data generation offers the advantage of creating anonymized or synthetic test data that mimics the characteristics of real data. All with the benefits of not exposing sensitive information. It allows testing at scale, without compromising data privacy due to using real production data.

UiPath testing activities

This blog additionally highlights the current set of activities that the UiPath.Testing.Activities Package has to offer, with an emphasis on the section Data. The section Verification is out of scope and used to validate your test case scenarios in the last stage of the the ‘Given-When-Then’ or ‘Arrange-Act-Assert’ structure when writing down test cases.

The seven activities below can help you generate various test data:

  1. Last name

  • Output-Type & Output-Details: LastName (Type: String – i.e. str_RandomLastName)

  • Input-Type & Input-Details: Not required / cannot be specified

2. Given name

  • Output-Type & Output-Details: GivenName (Type: String – i.e. str_RandomFirstName)

  • Input-Type & Input-Details: Not required / cannot be specified

3. Address

  • Output-Type & Output-Details: Address (Type: Dictionary – i.e. dictAddress) → Country, PostalCode, StreetNumber, StreetName, City I.e. dictAddress("StreetName").ToString

  • Input-Type & Input-Details: <Country>, <City> Randomly chosen value or specify

4. Random date

  • Output-Type & Output-Details: Random Date (Type: DateTime – i.e. DateTime_RandomDate) → Random Date (Time is always 00:00:00)

  • Input-Type & Input-Details: <Min>, <Max> Select in Calendar, or DateTime Variable (i.e. 2023/01/01)

5. Random number

  • Output-Type & Output-Details: Decimal (Type: Decimal – i.e. number_RandomDecimal) → Random Number with Decimals

  • Input-Type & Input-Details: <Decimals>, <Max>, <Min> Decimals 0 is allowed and per default; Min/Max as Long (no Decimals as Int64 is to be provided!)

6. Random value

  • Output-Type & Output-Details: Random Value (Type: String – i.e. str_RandomValue) Picks a Random Value (Row) from the selected CSV-File

  • Input-Type & Input-Details: <File> CSV-File

7. Random string

  • Output-Type & Output-Details: Random String (Type: String – i.e. str_RandomString)

  • Input-Type & Input-Details: <Case>, <Length> Lower, UPPER, CaMeL, MixED

There are other activities, mainly related to test data queues, which aren't covered within this blog.

Auto-generated test data in UiPath Studio

Alternatively, you can make use of the Auto-generated Test Data feature in UiPath Studio. Test data can be generated for an existing workflow in your Studio project, whereby data is generated based on arguments, i.e. to test multiple process instances in various If decision trees. This feature helps you to achieve better test coverage (i.e. for boundary conditions, edge cases).

Below is an example and step-by-step introduction on how to auto-generate test data:

First, check out the video in the UiPath documentation portal.

  1. Right-click an existing workflow and select Create Test Case.

  2. Enter a name for your test case and change the default location, if required.

  3. (Optional) Add test case to execution template like in this documentation post.

  4. In the Test Data tab, click Source and select Auto Generate from the dropdown list.

  5. Select the columns that you want to add, the individual columns are reflecting the arguments in your initial workflow.

  6. (Optional) Edit the data table values or delete entire rows and columns.

  7. (Optional) Click Add Row to generate another row of default values. You can edit the values.

  8. Click OK to confirm.

The data is generated and added to the test case. You can access the data through the arguments of your initial workflow.

Execution templates allow you to wrap test cases at runtime to use your defined execution conditions for multiple scenarios. Hence, instead of copying, pasting, and maintaining multiple test cases, you can create a single template that acts as a boilerplate to wrap the test cases at runtime.

Roman Tobler
Roman Tobler

CEO, Routinuum GmbH