Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

barbie (2653)

barbie
  reversethis-{ku. ... m} {ta} {eibrab}
http://barbie.missbarbell.co.uk/

Leader of Birmingham.pm [pm.org] and a CPAN author [cpan.org]. Co-organised YAPC::Europe in 2006 and the 2009 QA Hackathon, responsible for the YAPC Conference Surveys [yapc-surveys.org] and the QA Hackathon [qa-hackathon.org] websites. Also the current caretaker for the CPAN Testers websites and data stores.

If you really want to find out more, buy me a Guinness ;)

Links:
Memoirs of a Roadie [missbarbell.co.uk]
[pm.org]
CPAN Testers Reports [cpantesters.org]
YAPC Conference Surveys [yapc-surveys.org]
QA Hackathon [qa-hackathon.org]

Journal of barbie (2653)

Tuesday August 17, 2004
11:06 AM

DBI::Recorder

[ #20438 ]
For a while this has been at the back of my mind. I like Test::MockObject, but setting it up for mocking the DBI can be a bit long winded sometimes. I like what HTTP::Recorder does, and DBI::Profile is half way to where I want to get to.

I want a module that can do two things;

  1. to be able to implement what DBI::Profile does, in terms of recording the SQL query and storing to a file, but in addition stores the result set that is returned by the DB, and can append to the file if requested to. Reading the docs, I can't see whether or how DBI::Profile can do this.
  2. to be able to translate that data file into a format that can be quickly plugged into a Test::MockObject backend, an as yet unwritten Test::MockObject::DBI module.

The aim would be to run a test suite, which outputs a file with all the necessary information passing between the application and the database, which can then be munged into a format which can replace the database using Test::MockObject.

The problem I've encountered so far is that, DBI::Profile only records the SQL queries being sent, and it recreates the profile file for each invocation rather than appends data. However, using this as a starting point, there should be no reason that I can't implement something similar. I can't find anything that looks like it can do what I want on CPAN (or Randy Kobes' site), although that may just be me not asking the right question. Note that I'm not after DBD::Mock, as I'm not testing the database calls, just that the munging of the result set is as expected.

So has anyone else thought of something like this? Can DBI::Profile do this? Is there some other module that already does this, or something similar? Is anyone working on a soon to be released distribution that does this? I did wonder whether, like HTTP::Recorder uses HTTP::Proxy, whether I could use DBI::ProxyServer, but that looks to be far too much effort for what I want.

I'm a big advocate of using Test::MockObject instead of trashing someones database. So I thought making life a little easier for anyone who wants to do the same, but can't face writing all the data files for the test suite, would be a good thing.

In other news Mark Stosberg released another version of CGI::Uploader. I have been meaning to finish off the Test::MockObject style testing for him for several months. Having DBI::Recorder would make that so much easier ;)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • For your second item above, you can tell DBD::Mock to return results for either the nth SQL statement or for the statement matching the string x. So I don't think it would be too difficult to seed the database handle with the results from a given file -- something like a phrasebook with attached results. There aren't any hooks for creating such a file though.

    (Note that I'm no longer maintaining this module -- as of yesterday Stevan Little [cpan.org] has graciously taken it over at my request.)

  • ..find the tuits. I, for one, would find such a module immensely usefull.
    My tuit supply has completely dried out (why does the boss expect me to do actual work?), otherwise I would have tried to do something like it myself, but I would be happy to help in any way I can.
    • Well I'm surprised no-one has tried it before. I'm on holiday next week, so will try and grab some time to investigate DBI::Profile further, and see if there are additional hooks I can use to get at the data. I may look at DBD::Mock for the end result, as this would require less work on my part, and already works :)