• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

more clarification on @beforeclass

 
pavan bukka
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i am new to junit, i have been told that in @beforeclass we should write code to put data into databse can anybody tell why and how ?

with regards,
bukka pavan.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34851
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@BeforeClass runs once (vs @Before which runs once per test.) More costly operations that can be shared are good to put there. In the case of integration tests, that is common data setup.

Remember to clean up the data in @AfterClass. I also like to have my setup call the teardown first in case the database isn't a good state.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic