You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by akochnev <ak...@gmail.com> on 2009/01/13 07:03:41 UTC

PageTester and form validation

I have a page with a couple of required fields (set up in the template w/
t:validate="required"), as well as some custom validation in the page itself
(e.g. in the "validate" event handler that calls
registrationForm.recordError(...)). Despite the fact that there are missing
values in the map (for the fields marked w/ t:validate="required")that I
provide when calling pageTester.submitForm(...), and that the custom
validation fails, the page processing succeeds as if there were no
validation errors (e.g. the "submit" event is fired, etc).

Thus, I was wondering, is this expected behavior ? If PageTester doesn't
process the page templates (from where it can pick up that I requested a
"required" validation), it would still make sense that it would follow the
same event processing logic as a "non-test" processing (that is, if there
are errors registered in ValidationTracker, then don't process the "submit"
event and render the original page. 

If it is, what is the recommended method for testing pages & form
submissions including validation ? If I go the Selenium route, I can
probably do it all, but I really would rather first unit test the pages, and
only then do integration tests. If I go the "mock" route, then I have to
mock out a whole bunch of services (mine and T5's) that the page depends
upon. 

I'm still struggling a bit w/ testing pages. Using PageTester seemed like a
good compromise between going the full mock-route (where I'd have to mock
out a dozen things that are injected into the page class, both mine and T5's
services), and the Selenium route (where I have to give up a lot of the
control over the "test environment" of the page - to be expected for
integration testing). PageTester seemed to be a nice approach, as I could
provide a specific module with some mock services. However, with this
setback, when the events are not processed in the same way as "regular" T5,
then I really can't verify that the page navigation works as expected (as
the form submission would go through despite the invalid form data). 
-- 
View this message in context: http://www.nabble.com/PageTester-and-form-validation-tp21429986p21429986.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org