|We don't bite newbies here... much|
How to test different back ends?by skazat (Hermit)
|on May 31, 2007 at 06:01 UTC||Need Help??|
skazat has asked for the
wisdom of the Perl Monks concerning the following question:
I'm having a hard time understanding how I can test an application the supports more than one type of data backend.
For example, I have an app that can save its data in both a plaintext backend, and an SQL backend.
(Say) I have a module called, "App::Backend" that holds all the shared subroutines/methods, and two other modules, called, "App::Backend::PlainText" and App::Backend::SQL" which hold different versions of the same methods - anything that can't be shared.
App::Backend looks like this:
(App::Config just holds the configuration variables)
Say, App::Backend::SQL has a method, like this:
and App::Backend::PlainText has a method, like this:
My test file looks something like this:
It's wrong, because App::Backend is never refreshed and the, "use base" line is never called again. I've tried deleting it from %INC, but that doesn't seem to do the trick (and seems wholly wrong)
Changing the backend like this isn't something I ever want to do in code, but in testing, it's real useful to make sure every backend is checking out on the tests.
The only thing I can think of, is to make a test file for each backend, that are exactly the same, except that the $App::Config::Backend_Type is set to a different thing, before I call App::Backend->new;
Any other ideas? What do you all do to test the various backends in your app? Is my, "use base" way of doing things not the best? I'm starting to look at other packages, like CGI::Session on CPAN - looks like there's just different test files for each backend. Sigh.