Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Re: The Joy of Test

by drewbie (Chaplain)
on Apr 12, 2002 at 14:08 UTC ( #158578=note: print w/replies, xml ) Need Help??

in reply to Re: The Joy of Test
in thread The Joy of Test

A solution to that particular problem is to restructure a class to make use a "database interface" class that can be passed in either at object creating time or to a method that populates an instance of the object.

I like this idea a lot, and I do use a database wrapper for most code I write now. At some point I will probably write another wrapper to do what you mention.

I do have another suggestion, which is the approach I've been using lately. I'm trying to follow the MVC concept where it makes sense. Hence I have broken down the various data types into Model modules. They have a dependency on each other like: Change needs Event needs Provider. So I started at the top (Provider) and wrote the module & tests. It works great. Then I wrote the Event module. In the test for it, I use the Provider object I just finished to create dummy entries in the database. Then I run my tests on this known data and verify all is well. Then I delete everything at the end of the test. All is well and I've just used up a few auto_increment id's - no big deal.

The disadvantage to this approach is that while in development you'll most likely get quite a few invalid entries left in the database. In my case it's no big deal to clean them up by hand. You should keep this fact in mind when using this approach.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://158578]
[thezip]: Is there an analogy for '&' (ie. run commandline process in background) for Windows commandline?
[Corion]: thezip: start "some title" path\to\that\ application, but that will open another console window
[Corion]: thezip: If you want to confuse your users, use system(1, "that\\command" );, which will make Perl launch it in the background
[Corion]: That will keep the console window open even though the user can't type into it anymore
[thezip]: So I have a script that generates a log file. After script completion, I want tohave VIM open this logfile.
[thezip]: i don't get the command line "back" until I close VIM. No what I want to happen...
[thezip]: I currently don't have access to CYGWIN, else I'd just do a tail -f on the logfile.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-03-27 18:48 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (321 votes). Check out past polls.