in reply to Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject

It probably involves the way Test::MockObject replaces UNIVERSAL::isa and UNIVERSAL::can with it's own stuff. You really should not use this module from a non-test class. Both Class::DBI and Test::MockObject do a lot of perilous things in their code, so you are likely to discover other compatibility problems after solving this one.
  • Comment on Re: Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject

Replies are listed 'Best First'.
Re^2: Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject
by dragonchild (Archbishop) on Dec 13, 2005 at 20:53 UTC
    So, how should one use Test::MockObject to test code that uses CDBI?

    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?
      I would need some explanation of what is being attempted here before I could offer advice. Is it to test a mock of a CDBI class? To store some kind of T::MO state? I have no idea. In normal use, you call T::MO from a test script and use it to replace some other class.
        The original code did use T::MO from a test script. It didn't matter where I put the use Test::MockObject line - so long as it was included somewhere this problem occurred.

        Moreover, I don't think I was doing anything particularly unusual.
        I have an application with N subsystems. I'm doing a test of the interaction between 2 subsystems, one of which uses CDBI. I'm using TMO to mock up several other subsystems, completely unconnected to the CDBI section other than the fact that all of them are needed for this testcase. What do I do?

        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?