[infinispan-dev] Test framework and cleanup

Manik Surtani manik at jboss.org
Sat Oct 2 14:44:47 EDT 2010


Currently unit tests extending SingleCacheManagerTest or MultipleCacheManagerTest are cleaned up either after every test method or after all of the test methods declared in a test class, based on the value of the "cleanup" field which can be either CleanupPhase.AFTER_TEST or CleanupPhase.AFTER_METHOD.  This is typically set in the constructor of a test class.  E.g., 

http://fisheye.jboss.org/browse/Infinispan/branches/4.2.x/core/src/test/java/org/infinispan/context/InvocationContextTest.java?r=1801#l48

To simplify this even further, I have added 2 annotations to the test framework: @CleanupAfterTest and @CleanupAfterMethod.  Instead of setting the "cleanup" field in a constructor, you can now just annotate your test class accordingly.  E.g.,

@Test (... )
@CleanupAfterMethod
public class MyTest extends SingleCacheManagerTest {
... 
}

Note that the "old" pattern of setting "cleanup" will also work; using the annotation just makes tests more concise and readable.

Enjoy
Manik
--
Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org







More information about the infinispan-dev mailing list