Follow

JSON File As Data Provider

Use json file as data provider, you have to create json file in resources folder.Below is the example of json data file for login scenario.

    [
	{ "Username" : "admin" , "admin":"123abc123" , "isvalid":"false" },
	{ "Username" : "Admin" , "Admin":"test" , "isvalid":"false" },
	{ "Username" : "admin" , "admin@123":"Chirag2193" , "isvalid":"true" }
    ]

Following is the test where JSON 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 json file.

    	@QAFDataProvider(dataFile = "resources/logindata.json")
	@Test(description = "json file as data provider ")
	public void login(Map <String, String> data) {
		doLogin(data.get("Username"),data.get("password"));
		assertLoginMsg(data.get("isvalid"))
	}
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