How do you pass value to test method method? from your data provider

Solved 1 Answers 107 Views Programming
0 1

I am not sure how to pass username ,password values to my test method from my data provider. My @DataProvider looks something similar to this,


public Object [][] getData()


Object[][] data = new Object[1][2];

Hashtable<String, String> credential1 = new Hashtable<String, String>();

credential1.put("username", "admin");

credential1.put("password", "admin");

Hashtable<String, String> credential2 = new Hashtable<String, String>();

credential2.put("username", "admin");

credential2.put("password", "WCM2k8Ap");

data[0][0] = credential1;

data[0][1] = credential2;

return data;




1 Answer

Best answer

You can receive it like below.

public void myTest(Hashtable<String,String> credential1,Hashtable<String,String> credential2){
String username1 = credential1.get("username");
String username2 = credential2.get("username");


answered by
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

We have resolved 1.2k+ Software Testing queries!

Top Contributors