3.11.Data Driven Tests
Data Driven testing (DDT) is creation of test scripts where the input as well as results are accepted from an external data source. In the simplest form the tester supplies the inputs from a row in the table and expects the outputs which occur in the same row. In the context of Marathon, the input is the values that you set to the components and the expected results are what you provide in the assert methods.
MarathonITE also provides you a way to create a loop that is data driven. This is especially useful when you need to perform same set of operations multiple times such as creating a set of accounts.
MarathonITE's data driven framework has Create DDT and Create Data Loop refactorings that simplify creation of data driven tests. It also includes a CSV file editor for quick creation of data.
Marathon CSV Editor
Testing with External Data
In data driven testing, you provide the data from an external source. Marathon supports CSV format files for accessing the data. The header in the CSV file provides the variable names used in the test and each subsequent row contains the data for each test run or loop. The advantage of data driven testing is that you can add additional inputs to the data file for different cases without touching the test script. This segregation of test control and test data improves the maintainability of the test project.
Marathon Data Driven Tests
Marathon data driven tests are regular test scripts with a magic marker in the form of usedatafile in the test header. The usedatafile also provides the name of the test data file that contains the data. The data file has a header row that defines variable names and subsequent rows with the data. When Marathon encounters a data driven test – recognized by the usedatafile marker – it considers this test as a suite of tests with one test for each row in the data file. Marathon also reads the file and defines a global variable for each data column and assigns it with the value from the data column of the current row. If the first column name is marathontestname the name is appended to the test script name to create individual test names.