-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How to write Unit Test Case for Hibernate
PostPosted: Mon Dec 06, 2004 5:06 am 
Newbie

Joined: Sun Dec 05, 2004 4:37 am
Posts: 2
Location: bangalore
Hi all
I have to write unit test cases for the Hibernate classes.
I am not getting proper stuff for writing The test case.

can any body tell me that what to use for writing the test cases, and how to write that.if any Documentation is available the please let me know.

Its urgent.

thanks and regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 5:37 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Guess your test cases are suposed to manipulate persistent data.

I found the following set-up userfull:
  • Have a HiberanteTestCase which creates a SessionFactory once for the livetime of this test class. See the junit FAQ for more infos about this. If you want to run a lot of tests together do the same for a whole test suite. This saves you from initializing Hibernate for every single test.
  • Use DBUnit to have a consistent DB. I found DBUnit hard to get working, but once you're through it, it's a very handy tool. I integrated DBUnit into my HibernateTestCase class.
  • For convenience: Use a HibernateTransactionTemplate (visitor pattern), which saves you from doing the sam transaction handling stuff over and over again.


I'm using this set-up successfully withing eclipse with ~100 Testcases.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 6:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can also take a look at caveatemptor tests

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: could u please send me a sample code
PostPosted: Thu Dec 09, 2004 9:19 am 
Newbie

Joined: Sun Dec 05, 2004 4:37 am
Posts: 2
Location: bangalore
Could u Please send me a sample code

pradeep

ernst_pluess wrote:
Guess your test cases are suposed to manipulate persistent data.

I found the following set-up userfull:
  • Have a HiberanteTestCase which creates a SessionFactory once for the livetime of this test class. See the junit FAQ for more infos about this. If you want to run a lot of tests together do the same for a whole test suite. This saves you from initializing Hibernate for every single test.
  • Use DBUnit to have a consistent DB. I found DBUnit hard to get working, but once you're through it, it's a very handy tool. I integrated DBUnit into my HibernateTestCase class.
  • For convenience: Use a HibernateTransactionTemplate (visitor pattern), which saves you from doing the sam transaction handling stuff over and over again.

I'm using this set-up successfully withing eclipse with ~100 Testcases.

HTH
Ernst


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.