应用设计模式编写易于单元测试的代码[5]

发表于:2010-03-15来源:作者:点击数: 标签:代码单元应用模式编写
应用设计模式编写易于单元测试的代码[5] 单元测试工具 public Object getInstance() { try{ return this.getInstanceMethod.invoke(null); } catch (InvocationTargetException e) { if( e.getCause() instanceof RuntimeException ) throw (RuntimeExceptio

  应用设计模式编写易于单元测试的代码[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( IllegalAclearcase/" target="_blank" >ccessException e) {

  throw new IllegalArgumentException(

  "Illegal access to method ["

  +this.getInstanceMethod + "].", e);

  }

  }

  public Method getGetInstanceMethod() { 软件测试

  return this.getInstanceMethod;

  }

  }

原文转自:http://www.ltesting.net