Data-driven testing means using a single test to verify many different test cases by driving the test with input and expected values from an external data source instead of using the same hard-coded values each time the test runs. This way, you can test how the application handles various input without having a lot of similar tests that only have different data sets.
The data-driven testing approach can be used with unit and functional testing. It is especially useful in scenarios that are too cumbersome to execute with manual testing, for example, when an application needs to be quickly supplied a large amount of input values.
TestComplete supports data-driven testing and provides you with all of its advantages:
Create Re-Usable Automated Tests
Instead of having pretty much identical automated tests that consist of the same operations but differ in input and expected values, you can use data-driven testing to separate test logic from test data by replacing hard-coded values in your automated tests with variables. This way, you can create re-usable automated tests that can run repeatedly with different data sets supplied by an external data source.
Data-Driven Testing with Various Data Sources
TestComplete supports Excel spreadsheets, CSV files and just about any database including Microsoft SQL Server, Oracle, MySQL, Microsoft Access, Interbase and others for data-driven testing. You can also implement data retrieval from custom sources, such as XML or INI files.
Parameterize Data-Driven Tests Easily
The built-in data-driver wizard scans your automated test for fixed values in operations and checkpoints and lets you quickly parameterize some or all of them using values from the selected data source.
Quickly Generate Test Data
TestComplete’s integrated data generator helps you quickly create large volumes of random yet realistic test data in a variety of formats. Using the data generator, you can create hundreds and thousands of test data sets in just a couple of minutes instead of hours of tedious work that it would take to create the data manually.
There are predefined generation rules for names, e-mail addresses, street addresses, cities, states, phone numbers, social security numbers (SSN), dates, number ranges, strings and so on. You can also generate data based on custom value lists and combine standard generation rules to produce sophisticated output. The generated data can be stored directly to test variables, or saved to Excel files that can be used by multiple tests.
Store All Values in One Place
With the data-driven testing approach, all input data and expected results for your automated tests are kept in one place, which makes it easier to maintain test cases. To change a test case, you just need to change the appropriate values in the data source file; there’s no need to modify the automated test itself.
Execute Expressions Specified Within the Storage’s Cells
During the data-driven testing, you can also execute expressions specified in cells of the processed storage (for example, your storage can contain the value of 5+5). To execute this expression, you can either use the Eval function (in VBScript and JScript) or the Evaluate function (in DelphiScript). To do that, you need to obtain the expression first and then pass it as a parameter of the Eval or Evaluate function.
After you run your test, it will automatically retrieve the needed expression from the data storage, execute it and return its result (in the example described above, the test will return 10).
Add New Data-Driven Test Cases Quickly
Data-driven testing makes adding new test cases as easy as adding a new entry into the data source.
Data-Driven Testing Increases Test Coverage
By driving your automated tests with a lot of different data sets that cover various aspects of your application’s features, you can increase your automated test coverage.
Watch the data-driven testing video lesson to see how you can create data-driven tests with TestComplete.