Home | Validators The validator interface is implemented when validating something about a particular test action. Each action could have many validators associated with it. The particular action being validated is passed to the validator implementation, and JUnit's AssertionFailedError should be thrown when something fails validation. Test validator hierarchy Validators implement the Validator interface directly to receive executed action that will have the appropriate results. Actions that implement the MethodResultsAction will have a getResults() method to retrieve the objects. Other validators will have to know more information about the particular action being validated. WebPageContentValidator This validator works only with the WebSessionValidatedAction, and retrieves it's information from the HttpUnit response. Validated are:
MethodResultValidator The method result validator works with actions implementing MethodResultsAction. The results are retrieved from the action, and validator utilizes Spring's BeanWrapperImpl and PropertyValue objects to retrieve data from and validate fields in the results object. This validator also validates primitive objects and objects without standard Spring getter / setters. These include:
ThrowableValidator Sometimes the method being invoked should throw an exception. Validate this with the ThrowableValidator. The ValidatedAction will catch exceptions, and if validator list contains ThrowableValidators, they will be invoked to ensure that the exception thrown is appropriate. This validator just looks at the throwable class name ("com.company.Throwable" format) and the message. see Sample ThrowableValidator |
hosted by |