Oracles and Test Data Generation

In the testing lexicon, an oracle is a principle or mechanism by which we recognize a problem. Data generation is the exact opposite of an oracle. Rather than verify data, data is produced. Sometimes the rules surrounding our oracles and data generation are simple and straightforward. Other times they are algorithmic and/or complicated. Scripting languages excel at both these tasks.

In one company I worked for, the application would create entries in a number of different database tables in a number of different systems as the result of a single workflow. And of course each of those entries had different data integrity and business rules around them. Rather than check each of these manually, I wrote an oracle in Python that would take a transaction ID and then verify that everything was correct across the various systems. Just be careful that you actually know the business rules before you rely on this solely for verification purposes.

Because that system dealt with personal and financial information (it was for car dealers), there were a number of obstacles in terms of what was valid test data. I tried tracking accounts and other such testing information in a spreadsheet and later a wiki, but it never quite worked. Scripting came to the rescue. I created a number of scripts that could reach into the application’s database and tell me a valid user for a dealership with a valid credit bureau.

Actually, I combined both of these techniques with a Selenium ...

Get Beautiful Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.