• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unit test patterns with Hibernate

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a simple question for folks who have strong experience with using Hibernate. My question relates to best practices in terms of unit testing Hibernate code, particularly when the DAO pattern is used. In general, should unit tests be written just for the DAOs, just for the entities, or for both?

We are beginning a project, and I want to ensure that we provide good test coverage, while at the same time not spending more time than we need. I'd imagine that one answer to my question is "if you want complete coverage, then test the entity and the DAO layer", but I'm curious if, in practice, anyone has found it more efficient to omit tests for one or the other.

Thanks in advance!
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't test either unless you have a test generation tool that can reverse engineer tests from your DAOs. Assuming you have a common DAO pattern applied throughout your DAO layer all you will be doing is testing the same relatively small bit of code repeatedly. While this might be a good thing, you could end up with a large set of very basic tests you have to maintain. You will probably get enough coverage just testing the domain objects that use your DAO code.
 
He's giving us the slip! Quick! Grab this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic