1
我正在使用org.jnuit.Assert类来测试业务逻辑的单元。验证错误消息中的内容
如果在运行时出现特定情况,我的业务逻辑会抛出异常。一个特定的变量应该有非零值。
在我的catch块中,我想验证这个字符串消息:“变量var1应该有非零值”。
我想下面的代码段将工作,
try{
//business logic
}catch(Exception e) {
CharSequence charseq = "Variable var1 should have a non-zero value";
Assert.assertEquals("Variable var1 should have a non-zero value",true,e.getMessage().contains(charseq));
}
但它不工作。任何建议,我怎么能做到这一点?
感谢, 维杰Bhore