"be consistent" | |
PerlMonks |
Testing Model under CGI-based validationby jest (Pilgrim) |
on Dec 08, 2003 at 16:35 UTC ( [id://313134]=perlquestion: print w/replies, xml ) | Need Help?? |
jest has asked for the wisdom of the Perl Monks concerning the following question: I am finally making an effort to do some serious testing of my applications, and, starting with advice given to me here, began to try writing tests for my basic modules. Part of my setup includes ensuring that a user is logged in, a process which involves setting a CGI cookie holding the value of a server-side session ID that contains info on the user's access level, etc., held in a database. I had had some difficulty with part of this, as discussed in my thread OO: Leaving a constructor midway?; I ultimately "solved" it, if solve it I did, by handling the login and validation in a subclass and leaving the actual blessing in a superclass. In that node, pdcawley warned about the difficulty of testing this, and it is now coming true. In order for me to test the module I need to be accessing over the Web. I am also writing tests using WWW::Mechanize, but I want to be able to test the module on its own. Yet doing this would require (a) a CGI-held cookie holding (b) an existing session and (c) the ability to fake this from a test script. My login code, for example, looks roughly like this:
Suggestions to change the way the module validates users would seem to be off the mark, because I do need to validate them, and I thus need to test that. And it's not possible to skip the validation, even for testing purposes, because this module requires having a bunch of info that needs to come from the session. I'd be grateful for any thoughts wiser monks have.
Back to
Seekers of Perl Wisdom
|
|