应用设计模式编写易于单元测试的代码[5] 单元测试工具
public Object getInstance() {
try{
return this.getInstanceMethod.invoke(null);
} catch (InvocationTargetException e) {
if( e.getCause() instanceof RuntimeException )
throw (RuntimeException)e.getCause();
throw new IllegalArgumentException(
"Method [" +this.getInstanceMethod
+ "] has thrown an checked exception.", e);
} catch( IllegalAccessException e) {
throw new IllegalArgumentException(
"Illegal access to method ["
+this.getInstanceMethod + "].", e);
}
}
public Method getGetInstanceMethod() { 软件测试
return this.getInstanceMethod;
}
}
文章来源于领测软件测试网 https://www.ltesting.net/