I want to test that a particular request has validation errors. Is this possible? Something like:
assertEquals(true, Validation.hasErrors());
This doesn't seem to work.
I've attempted to use:
Validation.hasErrors();
Validation.current().hasErrors();
You could try with this the following:
In my model I have this:
@Email
@Required
public String email;
Then I can test it with:
myobject.email = "bademailbad.com";
Validation v = Validation.current();
v.valid(myobject);
assertEquals(true, v.hasErrors());
.. or ..
myobject.email = "bademailbad.com";
Validation.valid("email", myobject);
assertEquals(true, Validation.hasErrors());
Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.