File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes more clarification on @beforeclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "more clarification on @beforeclass " Watch "more clarification on @beforeclass " New topic

more clarification on @beforeclass

pavan bukka

Joined: Jan 01, 2013
Posts: 21
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

Joined: May 26, 2003
Posts: 33132

@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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: more clarification on @beforeclass
It's not a secret anymore!