Loading Excel data

We provide a NugetPackage that helps you import test data from an Excel (or csv) file. See a complete example on Github.

  1. Reference the following nuget package in your test case: Progile.ATE.Extensions.Excel

  2. Add a new class to your test case or model that defines the data structure that you want to import from the excel. For each column you want to import you need to add a property with the same name. The following types are supported: string, double, int, bool, DateTime. If a value can be empty, define the type as nullable (e.g. int?). If there are whitespaces in a column name, use a valid property name and give the column name in a the ExcelName attribute (see e.g. FirstRegistration in example).

  3. Load the test data like this: var testData = Excel.Load(@"TestData\TestData_Cars.xlsx").LoadSheet(); You can indicate the name of the worksheet and the row where the column header of your data is as parameter in LoadSheet. E.g.: LoadSheet("Sheet2", 5);

  4. Then you can either iterate through all rows of the test data with ForAll, get a random row with GetRandom or get a specific row with GetRow (index corresponds to row number in excel).

Last updated