Say I have a class and a method named testMethod(String test1, String test 2). I also have another class with different method which will call which ever method it is in. See the example below
public class functional {
testMethod(String test1, String test2) {
reCallMethod();
}
}
reCallMethod(){
testMethod(test1, test2); // ------> This has to be dynamic. I've written the method name as "testMEthod" here. But I want it generalized so that I can use this in any method and not just in "testMethod"
}
More information :-------------------------------
public class test1 {
public void TestCase1(String param1, String param2, String param3) {
try {
//Bla Bla Bla
}
catch (Throwable t) {
TestCase_Store_Locator_Verify_Page_Name(param1,param2,param3); //Retry running this method
}
}
}
public class test2 {
public void TestCase2(String param1, String param2, String param3, String param4, String Param5) {
try {
//Bla Bla Bla
}
catch (Throwable t) {
TestCase2(param1,param2,param3,param4,param5); //Retry running this method
}
}
}
Like TestCase1 and TestCase2 I have 500 Tests. Instead of doing above I will have a common method called retryLogic like below
public void retryLogic(){
//Call the test method in the class which this method is placed.
}
So my TestCase1 will look like
public class test1 {
public void TestCase1(String param1, String param2, String param3) {
try {
//Bla Bla Bla
}
catch (Throwable t) {
retryLogic(); //Retry running this method
}
}
}
public void TestCase2(String param1, String param2, String param3) {
try {
//Bla Bla Bla
}
catch (Throwable t) {
retryLogic(); //Retry running this method
}
}
}