應用設計模式編寫易于單元測試的代碼[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;
}
}
文章來源于領測軟件測試網 http://www.kjueaiud.com/