Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unit Testing when using Hibernate  RSS feed

 
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!