This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "more clarification on @beforeclass " Watch "more clarification on @beforeclass " New topic
Author

more clarification on @beforeclass

pavan bukka
Greenhorn

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30075
    
149

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


[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
 
jQuery in Action, 2nd edition
 
subject: more clarification on @beforeclass
 
Similar Threads
Security Exception: signature file
wrong @BeforeClass behaviour
Deprecated method SetReturnValue() in 2.4
Loading Common Data for testing using Junit
Testng is skipping @Before annotation from junit