ObjectMother pattern is a testing pattern to pull all common code used for
setting up business objects into one "factory".  Then your unit tests just
call upon this object to provide the setup objects for testing.  Its along
the lines of your makeXXXcall() methods in the test case you've referenced
below, but imagine if you had multiple testcases that needed this type of
setup for specific tests.  Instead of duplicating the above methods in each
test case, you would pull them together into a setup object or base class or
something to avoid the duplication.  This what the ObjectMother testing
pattern is about.

=================================================================
Jeffrey D. Brekke                                   Quad/Graphics
[EMAIL PROTECTED]                              http://www.qg.com


> -----Original Message-----
> From: Guido Sohne [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 30, 2002 12:40 PM
> To: Turbine Users List; [EMAIL PROTECTED]
> Subject: Re: Torque, junit and unit testing
> 
> 
> I've done some unit tests on code that uses Torque objects;
> 
> Some of my objects use data built from a lookup table in the
> database so I wanted to hit the database.
> 
> I also constructed mock objects (business logic objects)
> that used Torque objects. I recommend setting up a separate
> database specifically for testing so that you can rely on
> the data in there and test that it does indeed work.
> 
> My situation was to test code that did peak/offpeak billing
> on telephone calls based on start time and duration. The
> billing rates are pulled from a database and the results of
> the calculation are stored into the database, The unit tests
> checked that the calculations were correct but did not store
> the data ...
> 
> Please look at the URL below to see the code:-
> 
> http://sohne.net/cgi-bin/cvsweb.cgi/billing/WEB-INF/src/java/n
> et/sohne/billing/modules/UnitTests.java
> 
> What exactly is the Object Mother pattern ?
> 
> On Mon, Sep 30, 2002 at 10:42:25AM -0400, Rex Madden wrote:
> > Hi Jeff,
> > 
> > I'm looking to test the code that uses the objects, as I think I can
> > assume that the generated objects work.
> > 
> > It's funny that you mentioned the Object Mother pattern, 
> because I just
> > started using that as well.
> > 
> > For the mocks, are you building another layer on top of the 
> objects, or
> > are you adding hooks straight into the Peers?  I'm not sure if I can
> > conceptualize how you're doing that.
> > 
> > Either way, Torque doesn't seem well suited to automated 
> testing?  Maybe
> > I'm better off with Cocoon or OJB?
> > 
> > Thanks for the help,
> > Rex
> > 
> > 
> > 
> > -----Original Message-----
> > From: Brekke, Jeff [mailto:[EMAIL PROTECTED]] 
> > Sent: Thursday, September 26, 2002 10:00 PM
> > To: 'Turbine Users List'
> > Subject: RE: Torque, junit and unit testing
> > 
> > Torque/Turbine do provide some obstacles to the test infected.  In
> > situations where we don't want our tests to hit the db, we 
> just use the
> > generated om objects like they were pojo's and don't call 
> methods that
> > hit
> > the db like save().  We've also used small mocks or shunts 
> via an inner
> > class which does nothing in the save(), something like:
> > 
> > GeneratedOM om = new GeneratedOM
> >    {
> >         public void save() { }
> >    };
> > 
> > This does get tricky setting up your model with populated 
> objects.  We
> > ended
> > up with large setUp() methods to init our test fixtures, 
> sort of driving
> > towards something like the ObjectMother pattern (
> > http://www.xpuniverse.com/2001/pdfs/Testing03.pdf )
> > 
> > Are you wanting to test the generated objects or your code 
> that uses the
> > generated objects?
> > 
> > =================================================================
> > Jeffrey D. Brekke                                   Quad/Graphics
> > [EMAIL PROTECTED]                              http://www.qg.com
> > 
> > 
> > > -----Original Message-----
> > > From: Rex Madden [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, September 26, 2002 6:22 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Torque, junit and unit testing
> > > 
> > > 
> > > Hi,
> > >  
> > > I've been using Turbine without a database for a little 
> while and just
> > > started to take a look at torque for my persistence 
> layer.  I do a lot
> > > of automated unit testing in my apps and was wondering how people
> > > approached testing on top of the peer objects.  Usually, I 
> > > try to write
> > > the bulk of my tests to not actually hit the database, 
> since opening a
> > > connection to the db slows things down.  More often than 
> not, this is
> > > done with Mock Objects.  However, looking at Torque, it seems 
> > > that there
> > > aren't many interfaces to mock up.  In addition, the 
> generated peer
> > > classes all deal with the Torque singleton, which also poses some
> > > problems.
> > >  
> > > So my questions:
> > >  
> > > Is anyone doing XP type testing out there with Torque 
> WITHOUT hitting
> > > the database?
> > > If not, what kind of approaches have people been using 
> for db testing?
> > > 
> > 
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > 
> > 
> > --
> > To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to