Feeding external data
Tests can be fed data from any external data store such as a database, an Excel, or a CSV file or some external application that returns values dynamically and then can execute over the same data. To demonstrate this concept of test re-use further, we will undertake another exercise that focuses on performing the same task repeatedly. For the sake of the reader, we have abstracted the concepts now as these can then be implemented in whichever manner possible.
Basically, if we are having a set of repeatable tasks specified in a collection of values, then we can perform them in two different manners:
Perform the set of tasks repeatedly inside a test for each value
Perform the entire test repeatedly for the values
Performing a set of tasks repeatedly within a test
In this scenario, we create a test that takes in the argument or uses a variable containing a list of elements and iterate over it. As a precursor to this, first let us create the file containing the dynamic variable...