google搜索 51Testing站内搜索                    软件测试门户 | 软件测试培 训 | 文章资料精选 | 软件测试论坛 | 软件测试博客 | 测试招聘求职 
打印

Junit4 异常的测试问题

Junit4 异常的测试问题


待测类:
public Case{
   public void method() throws Exception{
      ......
   }
}

测试代码:
public TestCase{
   private Case case = new Case();
   @Test(expected = Exception.class)
   public void testMethod(){
     case.method();
   }
}

我的问题是,我在Eclipse里面,利用Junit4来测试抛出异常,但是Eclipse显示case.method()需要抛出异常,而不予执行。
请问我哪里写错了?

TOP

 
当前时区 GMT+8, 现在时间是 2008-9-7 03:25Copyright(C)上海博为峰软件技术有限公司 2001-2007 电话:021-64471599-8017
当您在访问网站、论坛及博客过程中遇到问题时可发送email:webmaster@51testing.com或发送论坛短信至管理员风在吹