Shreejit
Shreejit

Reputation: 11

Passing parameter externally to a TestNG class

My @DataProvider looks up some restful url as below. @DataProvider(name = "dbconfig") public Object[][] provideDbConfig() { Map map = SwaggerUtility.getSwaggerData("http://petstore.swagger.io/v2/swagger.json");

I ideally want a way to pass the url externally to the TestNG run or class. Is there a way to do that? Ideally the tests would be integrated with some CI tool which needs to pass the parameter down to the TestNG job. I do not see a way to pass parameters directly to a TestNG class. Please let me know if there is a way around

Upvotes: 0

Views: 113

Answers (1)

niharika_neo
niharika_neo

Reputation: 8531

You can pass it as an argument as a system level property - read it in your beforeclass method using System.getProperty("nameOfProp") and set a variable as you need for your class.

Upvotes: 1

Related Questions