How to Populate Tables with Randomized Dummy Data for App Testing

How to Populate Tables with Randomized Dummy Data for App Testing

Generating Random Test Data for App Testing

Introduction: When developing applications, having a set of dummy data to simulate real-world usage is crucial for effective testing. With the right formula, one can auto-populate tables with random data, ensuring a comprehensive test environment. This article elucidates how to seamlessly create bulk test records with varied random values for this purpose.

Why Dummy Data is Essential

Initializing an app with an empty table doesn’t give the full picture. Populating these tables with dummy records allows developers to validate functionalities like gallery control visualization, search operations, edit features, and to check for any delegation limitations that might hinder data retrieval.

Creating Test Records in Dataverse

Consider a table named ‘Property’ in the Dataverse for Teams database. This technique is also applicable to other data sources like SharePoint and Excel. The table encompasses various column types, from text to lookup columns referencing another table called ‘Property types’.

Basic Formula for Dummy Record Creation

With a simple formula, one can add 100 test records to a table. Here’s the foundational syntax:

    
Collect(Properties, 
        ForAll(Sequence(100,1,1), 
              {NewAddress:"Address " & Text(Value)}
        )
)
    
    

Generating Random Values

To make the test data realistic, it’s essential to generate random values. Whether it’s whole numbers, decimal values, dates, LookUp values, or boolean values, various formulas can be employed to produce the desired results. Refer to the official documentation on Rand function and Shuffle function for more detailed insights.

Compiling Test Records with Random Data

Integrating all the above formulae, one can curate records embedded with random values for various fields, enhancing the efficacy of app testing.

    
Collect(Properties, 
        ForAll(Sequence(100,1,1), 
               With({
                      roomRangeStart:1,
                      roomRangeEnd:8,
                      maxDays:(365*5)
                    },
                    {
                      NewAddress:"Address " & Text(Value),
                      PurchaseDate:
                         DateAdd(Now(),
                                 -1 * RoundDown(Rand()* maxDays,0)
                         ),
                      BedroomCount:
                         RoundDown(Rand()*(roomRangeEnd-roomRangeStart + 1) + roomRangeStart,0),
                      HasGarden: If((Round(Rand(),0) = 1),
                                 'GardenOption'.Yes,
                                 'GardenOption'.No
                               ),
                      PropertyKind: 
                         First(Shuffle(PropertyTypes))
                    }
               )
         )
)
    
    

Conclusion: Populating application tables with dummy data ensures thorough testing, thereby reducing potential issues when the app is live. This guide provides a foundational understanding of generating such data, ensuring app robustness and reliability.

If you encounter challenges or need further insights into creating random test records or any technical assistance, please feel free to contact us. Our experts are here to help!

About The Author