Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Automated testing of database classes

by dragonchild (Archbishop)
on Dec 27, 2004 at 20:23 UTC ( [id://417626]=note: print w/replies, xml ) Need Help??


in reply to Re: Automated testing of database classes
in thread Automated testing of database classes

Now granted, I'm testing just as much SQLite as I am my module, but the same it true at a certain level for DBD::Mock as well I guess.

Actually, it's not. DBD::Mock doesn't actually do anything. In fact, it doesn't even look at the SQL you gave it other than to verify you gave it something. What it does is say "The first statement executed will get resultset A and the second will get resultset B". That's it.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^3: Automated testing of database classes
by jk2addict (Chaplain) on Dec 27, 2004 at 20:37 UTC

    That is true, and I'm not disagreeing. But at a certain level, I'm still testing DBI, its use of DBD drivers and the DBD::Mock code. That was what I meant.

    If I'm going to depend on DBI+DBD+Mock to be in working order, I might as well go for the gusto and use a DBD driver that does something with the statements against a raw DB file I control during testing. That's just my opinion.

      But at a certain level, I'm still testing DBI, its use of DBD drivers and the DBD::Mock code.

      But it is black box testing. Which means you dont know or care the details of what DBI and DBD::Mock are doing, just that they respond to your code as you expect. And truthfully you're not testing DBI/DBD::Mock, but testing how your module works with them, and this is very important thing to test.

      If I'm going to depend on DBI+DBD+Mock to be in working order, I might as well go for the gusto and use a DBD driver that does something with the statements against a raw DB file I control during testing.

      One of the original design goals for DBD::Mock was that it be in a single file, so it was easily embedded in a module distro. SQLite is not that simple, since it relys on an external C library, which is sometimes asking a lot for people to install.

      Regarding the "that does something with the statements against a raw DB file I control during testing" part of your comment.

      You can have this same level of control and more with DBD::Mock. DBD::Mock will not throw away your statements, but will actually keep track of them as a list of objects you can get back and inspect. These objects not only hold the SQL, but also any bind parameters, number of results returned, etc etc. You cannot do this by using SQLite, you can only examine the side effects of your code in the database itself, which can lead to an explosion of database code to verify things like INSERTs, UPDATEs and DELETEs.

      dragonchild mentioned that you can add result sets in order, but you can also bind your results sets to particular SQL statements as well. This means that you are always guarenteed to get back a particular result set with a particular SQL statment. If you don't get it back, you get nothing, and your test should likely choke. With a SQLite database, you need to check the contents of your resultset before you can decide if something went wrong. This means testing with a higher level of granularity that would be nessecary with DBD::Mock.

      While DBD::Mock is far from "complete" it does have a number of other features as well, and as the current maintainer I am very open to suggestions as well as patches if you need it to do more.

      -stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://417626]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-29 13:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found