CodeVenture
CodeVenture

Reputation: 133

How to receive additional parameters in @Test (other than the ones obtained from DataProvider)?

I have a @Test testng method, which is receiving input from a Data Provider.

@Test (dataProvider = "createData")
public void testMethod(String id, String clientName){
    //some code
  }

I need to call the method from external code and pass in a third parameter (independent of DataProvider)

e.g. testMethod("ID887" "clientOne", rowNumber)

But this throws IllegalArgumentException, since the method is receiving only two parameters from DataProvider.

Can a method receive additional arguments?

Upvotes: 1

Views: 264

Answers (1)

Nathan Merrill
Nathan Merrill

Reputation: 8396

...as per the documentation, you can use Guice to inject other variables, and it will work with TestNG.

http://testng.org/doc/documentation-main.html#dependency-injection

Upvotes: 1

Related Questions