aspose file tools
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 Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 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: 31551

@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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: more clarification on @beforeclass