All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.formos.tapestry.testify.junit3.TapestryTest Maven / Gradle / Ivy

package com.formos.tapestry.testify.junit3;

import junit.framework.TestCase;

import com.formos.tapestry.testify.core.TapestryTester;

/**
 * JUnit3 base class for Tapestry tests. Note that test classes need to override
 * {@link #doSetUp()} and {@link #doTearDown()}. 
 * 

* I recommend that you create your own abstract class for you application tests * that subclasses this. You can then create a {@link TapestryTester} in that * class and store it in a static variable and also override * {@link #setUpForAllTestMethods()} for any other common setup. *

* For example: * *

 * public abstract class MyApplicationTest extends TapestryTest {
 *     private static final TapestryTester SHARED_TESTER = new TapestryTester(
 *             "pac.ka.ge", MyTestInfrastructureModule.class);
 * 
 *     public MyApplicationTest() {
 *         super(SHARED_TESTER);
 *     }
 * 
 *     @Override
 *     protected void setUpForAllTestClasses() throws Exception {
 *         MockitoAnnotations.initMocks(this);
 *     }
 * }
 * 
*/ public abstract class TapestryTest extends TestCase { protected final TapestryTester tester; /** * Creates a new instance using the given {@link TapestryTester}; you should * create this tester just once and share it across multiple tests, * for example by storing it in a static variable. * * @param tester * the tester to use (not null) */ public TapestryTest(TapestryTester tester) { assert tester != null; this.tester = tester; } /** * @deprecated Rename your method so that it overrides {@link #setUpForAllTestMethods()} */ @Deprecated protected void setUpForAllTestClasses() throws Exception { setUpForAllTestMethods(); } /** * See class javadoc for example: {@link TapestryTest} */ protected void setUpForAllTestMethods() throws Exception { // Do nothing by default } /** * Override {@link #doSetUp()} instead. */ @Override protected final void setUp() throws Exception { tester.injectInto(this); setUpForAllTestClasses(); doSetUp(); tester.collectForComponentsFrom(this); } /** * Override this instead of {@link #setUp()} */ protected void doSetUp() throws Exception { // Do nothing by default } /** * Override {@link #doTearDown()} instead. */ @Override protected final void tearDown() throws Exception { try { doTearDown(); } finally { tester.endTest(); } } /** * Override this instead of {@link #tearDown()} */ protected void doTearDown() throws Exception { // Do nothing by default } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy