in reply to Easier Mocking?

This is exactly what DBD::Mock was designed for ... kinda. Chris Winters, then stvn and I, planned DBD::Mock to be for people who use DBI directly. We have only just started playing with Class::DBI ourselves. It may be useful to come up with a way of mocking CDBI itself, because that's the interface you want to test, not DBI's interface. I suggest emailing the CDBI mailing list.

Some quick googling reveals http://www.spanner.org/lists/cdbi/2005/03/05/e66a0853.html, implying that DBD::Mock and CDBI don't work together out of the box, at least in that scenario.

Maybe Class::DBI::Mock needs to be written. I don't think it's a simple thing, though, given the amount of work that goes on behind the scenes in CDBI and how tightly some of it's coupled to other things.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^2: Easier Mocking?
by vampirechicken9 (Initiate) on Sep 27, 2005 at 15:11 UTC
    Maybe Class::DBI::Mock needs to be written. I don't think it's a simple thing, though, given the amount of work that goes on behind the scenes in CDBI and how tightly some of it's coupled to other things.

    I think that you could get away with using Class::Accessor to create the CDBI::Mock objects, and then loading them with canned data before returning them to the caller. But I must agree, that the poster would be well served in the long run by setting up a dev database.