All Downloads are FREE. Search and download functionalities are using the official Maven repository.

holmos.webtest.junitextentions.parameters.ParameterFrameWorkMethod Maven / Gradle / Ivy

There is a newer version: 1.0.2u10
Show newest version
package holmos.webtest.junitextentions.parameters;

import java.lang.reflect.Method;

import org.junit.runners.model.FrameworkMethod;
/**
 * 单个带有参数的方法,继承与junit的FrameWorkMethod类,参数的值可能来自于:
* 方法允许返回值 *
  • excel
  • *
  • cvs
  • *
  • database
  • *
  • xml
  • *
  • properties
  • * * @author 吴银龙([email protected]) * */ public class ParameterFrameWorkMethod extends FrameworkMethod{ /**当前的带参方法所在的执行序号,如果为-1则代表只执行一次*/ private int index; /**参数列表*/ private Object[] parameter; /**为单个方法运行索特别设置的字段,以后如果找到好的解决方案的时候再行改掉*/ private String methodName=null; public ParameterFrameWorkMethod(Method method,Object[]parameter,int index){ super(method); this.parameter=parameter; this.index=index; this.methodName=method.getName(); } @Override public String toString() { if(methodName!=null)return methodName; StringBuilder info=new StringBuilder(getName()+'<'); if(null!=parameter) { for(Object value:parameter){ if(value instanceof String){ info.append("\""+value+"\""+","); }else if(value instanceof StringBuilder){ info.append("\""+value.toString()+"\""+","); }else if(value instanceof Number){ info.append(value+","); }else if(value instanceof Character){ info.append("\'"+value.toString()+"\'"+","); }else if(value instanceof CharSequence){ info.append("\""+value.toString()+"\""+","); }else{ info.append(value.toString()); } } info=new StringBuilder(info.substring(0, info.length()-1)); } info.append(">["+(index+1)+']'); return info.toString(); } /**覆盖父类的执行方法,其实并没有做出一点修改,只是为了显示此处是做了修改,在此声明而已*/ @Override public Object invokeExplosively(Object target, Object... parameter) throws Throwable { Object result=super.invokeExplosively(target, this.parameter); return result; } public String getMethodName() { return methodName; } public void setMethodName(String methodName) { this.methodName = methodName; } }




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy