Follow

TXT File As Data Provider

Use txt file as data provider, you have to create txt file in resources folder.Below is the example of txt data file for login scenario in which first row is header.

recId,Username,password,isValid,expectedMsg
	Wrong Password,admin,admin,false,Invalid Username Or Password. Please Try Again.
	Wrong Username and Password,Admin,Admin,false,Invalid Username Or Password. Please Try Again.
	Wrong Username,admin,admin123,false,Invalid Username Or Password. Please Try Again.

In the above data file we can see recId parameter. recId is predefined field of QMetry Automation Studio and can be used to identify test case in report. Below is the example of generated report.

Following is the testcase where TXT data provider used to provide set of data. The testcase is executed 3 times as there are 3 set of data in data file.@QAFDataProvider contain dataFile which contain path of TXT file.

@QAFDataProvider(dataFile = "resources/logindata.txt")
	@Test(description = "login validation message " , groups={"p1" , "p2"})
	public void login(Map <String, String> data) {
		doLogin(data.get("Username"),data.get("password"));
		assertLoginMsg(data.get("isvalid"))
	}

Generated Report:

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

0 Comments

Article is closed for comments.
Powered by Zendesk