There's more than one way to do things | |
PerlMonks |
Web testing without the web server.by kyle (Abbot) |
on Mar 27, 2009 at 15:53 UTC ( [id://753696]=perlquestion: print w/replies, xml ) | Need Help?? |
kyle has asked for the wisdom of the Perl Monks concerning the following question: I have the opportunity to write a web application from scratch, and I really want it to be as testable as possible, and I'd like to hear from the monks about how to do that. What I'd really like to avoid is some variant on full blown web client to web server communication for testing. I don't want to write Selenium scripts (though I might, just to check the templates), and I don't want to spawn a baby web server when I'm testing (though a baby database doesn't bother me). The approach I'm considering right now is to write the controllers with an interface that simply takes CGI-ish parameters and returns data ready for the Template. So: data structure in, data structure out. The actual Catalyst controller can then be a thin wrapper around these testable components. I see that CGI has a save() method, and it can load its save files, but it appears those save files don't include things from the environment like the remote IP address, browser's user agent string, or other things I might want to use to taylor content. Because of this, I think I need to do more work to "mock" parameters to a controller. Just creating a new CGI object from passed in parameters isn't enough. Has anyone else out there faced this, written this, done this? Is there an article on the best way to go about what I'm talking about? I have the chance to do this right from the start, so any ideas would be welcome!
Back to
Seekers of Perl Wisdom
|
|