• 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

Is there a useful unit test for named queries?

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I generally aim for 100% test coverage (when speaking about the union of unit, integration, and acceptance tests). I generally try to get close to 100% for the unit tests alone as well; however there are times when it doesn't seem useful.

Currently I'm bumping into one of those boundary places.

I have code in a Repository like


Which doesn't seem to be unit testable (easily integration testable using DbUnit, however).

Most of my unit tests in the repository are probably a little towards the "silly" end of things -- typically mocking out the entityManager and just making sure that the right transforms of the incoming arguments are proxied through. At times there is more important logic that needs to be tracked.

Is there a useful way of unit testing the above function? Is there a suggested refactoring to the Repository class to allow better testability in this case?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,
If you want to unit test it, you are correct that you need to mock out the entity manager. Which should be easily mockable since it injected.

[edited to fix typo]
[ September 09, 2008: Message edited by: Jeanne Boyarsky ]
 
Politics is a circus designed to distract you from what is really going on. So is 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