Data-Driven Testing with Eggplant Functional
The data-driven approach to testing provides an efficient, easy-to-manage method of performing repetitive tests that use a set of test data. Eggplant Functional and SenseTalk include various features that make data-driven testing simple.
Eggplant Functional supports the use of test data from various data sources, such as plain-text files, Microsoft Excel files, and databases, and SenseTalk includes commands and functions to access, manipulate, and parse data in powerful ways. This article demonstrates how to use Eggplant Functional to incorporate data-driven testing into your scripts.
You can also perform data-driven testing by using the Tables feature in Eggplant Functional and associating a data file with a Table test.
For information about using data files to create a keyword-driven framework, see Creating a Custom Keyword-Driven Framework.
What Is Data-Driven Testing?
Data-driven testing is the concept of using an external data set as test input. The test might use input data in various ways, such as to specify text that is entered into a form on the application under test, to validate displayed values against expected values, or to establish a set of test constants.
The test is written generically using parameterization, such that it is able to receive the data in the data source. The data used by the test can be altered by manually editing the original data source, pointing the test to a new data source, or automating updates to the data source.
In the sections below on connecting to data sources, the sample SenseTalk code shows examples of using external data for data-driven testing.
Data Sources
A data source, which contains the test data for use in automation, is required for data-driven testing. Eggplant Functional supports the following data source types:
- Plain text (.txt, .csv, .xml, etc.)
- Excel (.xlsx)
- Open Database Connectivity (ODBC) databases
The data source you use determines both how you use SenseTalk to access the data source and how you parse the data.
Data Source Storage
When you use plain-text or Excel data sources, the file must be accessible to the local file system of the Eggplant Functional machine, which can include networked or shared drives.
If you're using Eggplant Functional on Windows, shared drives must be mapped to letters (e.g., D:\). UNC paths are not supported.
The suite Resources pane provides a simple method for storing plain-text and Excel data files within your suite. You can then easily reference those files from your scripts by using the ResourcePath() function.
For databases, communication between Eggplant Functional and the database is managed by an ODBC Administrator configured on the Eggplant Functional machine.
Plain-Text File Interaction
Using a plain-text file is often the simplest way to implement a data-driven testing strategy with Eggplant Functional.