Hello,
I am writing junit test for validators. Below code works:
However below doesn't work in junit - the difference here is that i am sending an additional parameter to display in the error message, Any idea how to write junit for this?Code:// 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);
Error i get in this case is:Code:errors.rejectValue("typeInput", "mismatch.LaunchQueryForm.typeInput", new Object[] { launchQueryForm.getTypeInput() }, null);
Thanks in advance for looking into this.Code:java.lang.AssertionError: Expectation failure on verify: BindingResult.rejectValue("typeInput", "mismatch.LaunchQueryForm.typeInput", ["X"], null): expected: 1, actual: 0
Best,
Prasad


Reply With Quote
