2
我不能运行我的测试,因为测试得到红色波浪错误线在我需要使用任何的try/catch或添加抛出这个说法decorator.decorate(new EncoderColumnDecorator())
。 这是错误消息。 未处理的异常的Junit
为什么我必须把任何的try/catch或抛出异常时,我已经有 “预期”
我的单元测试的属性:
@Test(expected=DecoratorException.class)
public void testDecorate_exception() {
decorator.decorate(new EncoderColumnDecorator()); -----Error in this line
}
方法测试
@Override
public String decorate(Object arg0) throws DecoratorException {
try{
//some code
}
}catch(Exception e){
throw new DecoratorException();
}
return arg0;
}
}
该方法抛出一个异常,需要使用它来抛出/尝试的任何方法...赶上它。这包括JUnit方法。 – pietv8x