Reputation: 171
Code Snippet:
@Test
@Parameters({"a,b"})
public void submitLogin(String a , String b){
//Code here
}
Error Displayed in Console: Method submitLogin requires 2 parameters but 1 were supplied in the @Test annotation.
Upvotes: 1
Views: 5614
Reputation: 1966
The @Parameters allows you to specify the parameter names, whose value you put in the testng.xml file; Each parameter name must be a string. In your case you clubbed both the parameter names[ a, b] into one single String. The solution would be:
@Test
@Parameters({"a", "b"})
public void submitLogin(String a , String b){
//Code here
}
And in your testng.xml define values for these variables as :
<parameter name="a" value="foo"/>
<parameter name="b" value="bar"/>
And yes, the order of annotations, @Parameters and @Test should not matter.
Upvotes: 1
Reputation: 4981
Try to use Parameters annotation before Test one. And each parameter should be quotation marked.
@Parameters({"a","b"})
@Test
public void submitLogin(String a , String b){
//Code here
}
Upvotes: 1
Reputation: 530
Don't you think that you are trying to pass one parameter "a,b" instead of two "a","b"?
Upvotes: 1