Hi. I use seam 2.0.1 and have a jsf validator/seam test question.
Assume I have the following test:
public class RegisterAccountActionBeanFacesTest extends SeamTest { @Test() public void testSuccessfulRegistration() throws Exception { new FacesRequest() { @Override protected void updateModelValues() { setValue("#{registeraccount.username}", "ErikEriksson"); } @Override protected void invokeApplication() { assert invokeMethod("#{registeraccount.register}").equals("success"); } }.run(); } }
It is for testing my method 'register' on the Seam component 'RegisterAccount'.
I have a validator attached to the inputfield for username. The validator is implemented as a Seam component (not implementing the Validator) with the methodsignature
public void validateUsername(FacesContext context, UIComponent tovalidate, Object value)
Can I trigger this validator upon the call of the'register' method in the test? or do I have to assert the validator methods instead of
the register method (that relies on the fact that the validator does its job)?
You probably want to run the validator inside the processValidations() phase, so override that method and call your validator (which will be tough as you are passing in the UIComponent...)