in reply to Re^2: Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject
in thread Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject

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.
  • Comment on Re^3: Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject

Replies are listed 'Best First'.
Re^4: Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject
by Mutant (Priest) on Dec 13, 2005 at 21:29 UTC
    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.
      Using Test::MockObject from a subclass of Class::DBI is so unusual that you're probably the first person ever to do it. That still doesn't tell my why you did it though. What were you trying to do?
        Perhaps I haven't explained the problem correctly. I'm not using T::MO from a Class::DBI sub-class. I'm using it from a test script (the above two piece of code can be in different files). The create() call doesn't have to be in the test script either (or the CDBI class), it just has to be in a piece of code called by the test script.
Re^4: Strange bug involving mysql, auto_increment, Class::DBI and Test::MockObject
by dragonchild (Archbishop) on Dec 14, 2005 at 01:48 UTC
    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?
      In the scenario you describe, there is no reason that your test script would inherit from Class::DBI or that your CDBI class would use T::MO. Using T::MO and calling CDBI objects in the same test script is not a problem, and my company does this in our tests without issues. That is not what is being shown in this example. Mutant is using T::MO from a Class::DBI class, not from a test script.

      I am honestly not trying to be difficult and I have no stake involved in the success of T::MO or CDBI, but I really don't see any reason to use these modules in the way that is shown here. The whole point of T::MO is that the modules being tested don't even know it's being used.