This week's book giveaway is in the HTML, CSS and JavaScript forum.
We're giving away four copies of hapi.js in Action and have Matt Harrison on-line!
See this thread for details.
Win a copy of hapi.js in Action this week in the HTML, CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unit Testing when using Hibernate

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Unit Test to write Test Cases aganist Hibernate implementation and i am using HSQLDB
Don't we need to load the hbm files inside the setup method of the Test case

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My opinion: if you are configuring your SessionFactory in your test you are not testing your application you are testing something else.

If you use Spring you can inject your SessionFactory into both tests and application.

If your code is written with testing in mind you can configure it to run against mock obejcts, which is my personal preference since you remove the overhead of creating an maintaining a test data set.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My opinion: if you are configuring your SessionFactory in your test you are not testing your application you are testing something else.

(hey paul , i am not using Spring Framework .)

Please tell me What do you mean by the above statement .I am trying to test the Mapping Configuration files one to many , and then the DAO operations . whats wrong with my approach ?
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or Please tell me will it be a good approach if i get access to the SessionFactory and session inside my testMethod??

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody please
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!