Hi All,
I'm developing a set of unit/integration tests using HttpUnit. So far went fine checking the functionality of the system. However, I'm facing the problem for checking the validation errors.
Scenario is like this
a) On a page , we enter few values in the form and click on submit.
b) If the values entered pass through validations (Client Side) then
it is pushed to the
servlet for further processing.
So far, on happy path and other alternative paths, where in input values pass the validation is working fine.
c) Now I need to provide some wrong data and the input page should be returned back saying asking to correct the values.
Implementation of the point "C" is not yet finalized, but we assume that error messages are displayed beside the corresponding form elements with some red color.
Now the challenge I have here is to parse the response and assert that proper error messages are displayed for the wrong data.
The approach, which I'm thinking is to parse the response (WebResponse) and make DOM tree, since basically the response is a html. Once this is done, I need to handle each of these elements separately. I tried to use JDOM but failed, as the response I may get back may not be well formed. So I need to make a similar API like JDOM or some thing else to accomplish this. I get a feeling that, I'm trying to reach my nose from the other direction round back my head. Can some one suggest me a better solution here.
By the way, we are permitted to use
JUnit and HttpUnit only.