假设我有一个类和一个名为 testMethod(String test1, String test 2) 的方法。我还有另一个具有不同方法的类,它将调用它所在的方法。请参见下面的示例
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"
}
更多信息 : - - - - - - - - - - - - - - - -
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
}
}
}
像 TestCase1 和 TestCase2 我有 500 个测试。而不是上面做的,我将有一个名为 retryLogic 的通用方法,如下所示
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
}
}
}