Testing databases with DBIx::Class
Nicholas Clark
nick at ccl4.org
Tue Jan 10 12:41:52 GMT 2012
On Tue, Jan 10, 2012 at 12:19:19PM +0000, Peter Sergeant wrote:
> On Tue, Jan 10, 2012 at 9:56 AM, Ian Knopke <ian.knopke at gmail.com> wrote:
>
> > I need to test some DBIx::Class code where the database may not be
> > available. I can set up something to generate a small, temporary
> > SQlite db, but I was wondering what approaches others are currently
> > using for this. DBD::Mock seems ok but not especially well suited for
> > use with DBIx. What does the rest of the community currently do?
> >
>
> I've tried a few approaches with this. Where I've used a different DB
> backend, I've been bitten by differences in the DB from Unicode handling to
> different feature sets. Where possible, a blank(ish) testing database
> running the same DB software as the target is infinitely preferable to
> faking it with a different system.
Yes, at ex-employer, it came to pass that trying to test a MySQL database
using fixtures in SQLite produced a steady stream of work trying to cope
with differences between the two, which only emerged as one tried to write
tests for more parts of the system.
(eg differences in SQL, what functions are named, emulating functions,
that in SQLite everything is a string)
Whereas building a system using MySQL's fast flat file loader paid off in
the medium term, as it eliminated needing to code around differences,
because the test database system was pretty much identical to the real
thing.
Nicholas Clark
More information about the london.pm
mailing list