2
我正在为验证器编写junit测试。下面的代码工作:Spring验证器Junit错误
// initialize errors
errors = createNiceMock(BindingResult.class);
errors.rejectValue("orgId", "mismatch.LaunchQueryForm.orgId");
// activate the mock
replay(errors);
// go ahead and run validate now
launchQueryValidator.validate(launchQueryForm, errors);
// verify the errors
verify(errors);
但是低于在JUnit不起作用 - 区别这里是我发送一个额外的参数错误消息显示,不知道如何写的JUnit呢?
errors.rejectValue("typeInput", "mismatch.LaunchQueryForm.typeInput",
new Object[]
{ launchQueryForm.getTypeInput() }, null);
的错误,我在这种情况下得到的是:提前
java.lang.AssertionError:
Expectation failure on verify:
BindingResult.rejectValue("typeInput", "mismatch.LaunchQueryForm.typeInput", ["X"], null): expected: 1, actual: 0
感谢您寻找到这一点。
最佳, 普拉萨德
得到这个workign在过去的这个样子,我很好奇其他方式为我的JUnit设置充满了EasyMock的。无论如何,谢谢你的注意。 –