[write what the boyos have done]
Gluing the KWDT class and the code that Freeman and Latisha have written ... and in the end I decided not to use dynamic class loading.
This is the basic of KWDT [link to the implementation of kwdt].
In nutshell, to handle pressing of button object.
But, a problem arises since the code needs to handle the object based on the type of action:String AUT = "app";
String objtype = "button";
...
Class c = Class.forName("com.fnis.application."+AUT+".object."+objtype);
button uiObj = (button) c.newInstance("login");
uiObj.press();
It is apparent that the code needs to have a lot of "if .. else ..." statements to cover each action, and to minimize the branch statement, I settled for Reflection. It cuts the "if ... else ..." statements down to nothing.String action = "validateenabled";
...
if (action.eq("press")) {
uiObj.press();
}
else if (action.eq("validateenabled")) {
uiObj.validateenabled();
}
else {
// action not handled yet
throw ...
}
Hopefully, using Reflection won't kill the performance of the test code.import java.lang.reflect.*;
String AUT = "app";
String objtype = "button";
String action = "validateenabled";
Class c = Class.forName("lib.applications."+AUT+".object."+objtype.toLowerCase());
Constructor ct = c.getConstructor();
Object arglist[] = new Object[6];
arglist[0] = window;
arglist[1] = objName;
arglist[2] = data;
arglist[3] = expectedResult;
arglist[4] = timeout;
Object obj = ct.newInstance(arglist);
Method m =c.getDeclaredMethod(action);
No comments:
Post a Comment