【发布时间】:2011-11-15 23:42:33
【问题描述】:
Eclipse 的 CodePro 生成 JUnit 测试,但是,它生成的所有测试方法都会抛出 Exception,即使不可能抛出已检查的异常。这是 CodePro 的限制,还是我以前从未见过的良好 JUnit 实践?
例如:
@Test
public void testCategory_1()
throws Exception {
String categoryName = "";
Category result = new Category(categoryName);
// add additional test code here
assertNotNull(result);
assertEquals(null, result.getCategoryName());
}
new Category(String) 和 result.getCategoryName() 不抛出任何已检查异常。
【问题讨论】:
-
我看不出这有什么好处。
标签: java eclipse junit codepro