Chinaunix首页 | 论坛 | 博客
  • 博客访问: 174782
  • 博文数量: 46
  • 博客积分: 1445
  • 博客等级: 上尉
  • 技术积分: 448
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-27 22:20
文章分类

全部博文(46)

文章存档

2013年(4)

2012年(12)

2011年(3)

2010年(5)

2009年(16)

2008年(6)

我的朋友

分类: Java

2010-11-18 17:06:08

public class Summer{
   private int methodone(String argsone){
      //method code

      .......
      return 4;
   }
}

测试如下:
public class SummerTest extends TestCase {
   public void testMethodone(){
      Object rightResult = xxxxx;
      Summer example = new Summer.newInstance();
      Method m = example .getClass().getDeclaredMethod("methodone",new Class[]{String.class});
      m.setAccessible(true);
      Object result = m.invoke(example ,new Object[] {new String(xxxx)});
      m.setAccessible(false);
      if (result.equals(rightResult)){
         //your code

         ......
      }
   }
}


阅读(475) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~