Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

Testing database driven application?

Thread view: 
howa - 05 Jan 2007 05:13 GMT
are there any recommendation in testing database driven application?

since most method calls are in fact query to the DB, so difficult to
automate the whole process when using JUnit...
Michael - 05 Jan 2007 07:22 GMT
> are there any recommendation in testing database driven application?
>
> since most method calls are in fact query to the DB, so difficult to
> automate the whole process when using JUnit...

Break the application into two parts in your mind:
1) Part that talks to database
2) Everything else

To test 1, write tests that call the functions that deal directly with
the database.  If there's any complex logic in generating the query or
anything like that, test it.  These tests will also let you know
immediately if something changes in the database (e.g., someone else's
project requires a database refactoring).

To test 2, use mock objects.  Basically, your code does something that
expects a database call with parameters x and y returning z.  The mock
object asserts that the parameters are x and y, and returns z, without
talking to the actual database.

Where these unit tests come in really handy is you can get at the
low-level stuff a lot easier than having to start up your whole
application and run it.

At my last company, we also implemented "database consistency check"
unit tests - basically these would run a series of queries with
expected results and confirm.  Things that were more complicated than
could be conveniently put into triggers or elsewhere in the database.
This gave us a 'trip wire' that let us know if some process was
entering subtly wrong data, and we'd catch it soon enough to fix it.

Michael
howa - 05 Jan 2007 14:06 GMT
Michael 寫道:

> > are there any recommendation in testing database driven application?
> >
[quoted text clipped - 28 lines]
>
> Michael

thanks.
Lord0 - 10 Jan 2007 15:47 GMT
You may want to google for JMock


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.