I've method like this,
public void beforeTest(String a, String b, String c, String d) {
x = getURL(a, b, c, d);
--------
--------
}
I now want to pass String[] instead of individual Strings as arguments type, so tried this,
public void beforeTest(String[] args){
x = getURL(a, b, c, d);
--------
--------
}
and passed a,b,c,d as command line arguments, my code isn't working, is it the right approach?
Thank you all, I did try getURL(args[0].......) approach and unfortunately I'm still getting the same error,
[testng] FAILED CONFIGURATION: @BeforeMethod beforeTest [testng] org.testng.TestNGException: [testng] Method beforeTest requires 1 parameters but 4 were supplied in the @Configuration annotation.
By the way, my getURL method is defined as below,
protected String getURL(String a, String b, String c, String d) {
if (condition){
return a
} else if (condition) {
return b
} ....
getURL(args[0], args[1], args[2], args[3]);getURL( args[0], args[1], args[2], args[3] )but you probably want to do some checking before to make sure you got the right number of arguments.beforeSuite(String ... args)you don't have to touch client code.