1. 封装常用函数。
automation.base.cons // 收集多处会使用到的常量, 当需要修改时,只需修改此处。
public class BaseCons{
public static final String DEBUG_MODE = "debug";
............
}
automation.base.core // 把常用操作收集到这个类中, 比如 获取环境变量, 浏览器类型等, 关于 抽象类可以参考 : http://blog.csdn.net/oh_mourinho/article/details/8216023
public abstract class Abstract {
@BeforeMethod(alwaysRun = true)
public void beforeMethod(ITestContext context, Method method){
try{
logger.info("[SetUp]Test Case ID:" + method.getName() + "====BaseBeforeMethod start");
//Get environment
logger.info("[SetUp]Test Case ID:" + method.getName() + "====current env: " + Util.getEnvStr());
//Get user type
String userType = null;
AutomationAnnotation annotation = method.getAnnotation(AutomationAnnotation.class);
if (annotation != null) {
userType = annotation.userType();
}
logger.info("[SetUp]Test Case ID:" + method.getName() + "====Get user type successfully.");
//Get user by type
UserBean user = UserManager.getUser(userType);
logger.info("[SetUp]Test Case ID:" + method.getName() + "====Get the user you want successfully.");
//Add user into TestObjectManger
logger.info("[SetUp]Test Case ID:" + method.getName() + "====Add the user into TestObjectManager...");
TestObjectManager.addUser(method.getName(), user);
logger.info("[SetUp]Add test case ID: " + method.getName() + ", user: "+TestObjectManager.getUser(method.getName())+" into TestObjectManager successfully.");
// Get browser info.
String browserType = Util.getBrowserType();
String browserVersion = Util.getBrowserVersion();
String platform = Util.getPlatform();
logger.info("[SetUp]Test Case ID:" + method.getName() + "==