How can I make a test Data driven?

To make any test data driven you can use QAFDataProvider annotation on test method. You can provide data in CSV, JSON, MS-Excel file or from database.

@QAFDataProvider(dataFile = ” resources/data/searchText.csv “)
@QAFDataProvider(dataFile = “resources/data/searchText.json”)
@QAFDataProvider(dataFile = “resources/data/testdata.xls”)
@QAFDataProvider(dataFile = “resources/data/testdata.xls”, sheetName=”TC2″)
@QAFDataProvider(dataFile = “resources/data/testdata.xls“, labelName=”TC2″)
@QAFDataProvider(sqlQuery = “select col1, col2 from tbl”)

To configure using property


global.testdata=dataFile = “resources/data/${class}/${method}.csv”
global.testdata=dataFile = “resources/data/testdata.xls”; sheetName=“${class}“;labelName=“${method}”
global.testdata=dataFile = “resources/data/${class}.xls”; sheetName=“${ method }“


In above example you can notice ${class} and ${method} parameters are used which you can use as per your requirement.

To set data provider parameters for individual test method you can provide property as below:

<tc_name>.testdata =[<param>=value]

TC02.testdata=dataFile = “resources/data/testdata.xls”; sheetName=”TC2“
TC01.testdata= sqlQuery = ” select col1, col2 from tbl “

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk