Share and Enjoy

David Saff's blog of technological joys.

Wednesday, August 09, 2006

 

BeforeClass and AfterClass on Suites

The documentation of JUnit 4 does leave out some feature gems, including this:


@RunWith(Suite.class)
@SuiteClasses({ATest.class, BTest.class, CTest.class})
public class MyTests() {
@BeforeClass public void setupDatabaseBeforeEverything() { ... }
@AfterClass public void teardownDatabaseAfterEverything() { ... }
}


This will run


setupDatabaseBeforeEverything
ATest
BTest
CTest
teardownDatabaseAfterEverything

Comments: Post a Comment





<< Home

Archives

February 2005   June 2005   March 2006   August 2006   December 2006   April 2007   May 2007   January 2008  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]