1.想要在case运行时,获取当前运行的类名和方法名可以通过如下代码实现
this.getClass().getSimpleName() + ":" + new Exception().getStackTrace()[1].getMethodName()
2.如果写在base文件里,每次运行时获取一遍接口名,获取不到方法名。所以这里通过反射来获取,具体如下
@AfterMethod
public void getMethodName(Method method){
String currentMethodName = method.getName();
}