carbidecpp20devenv/plugins/org.eclipse.test.source_3.3.0.v20080507/src/org.junit4_4.3.1/junitsrc/junit/extensions/TestSetup.java
author Matt Salmo <matt.salmo@nokia.com>
Wed, 09 Sep 2009 10:28:21 -0500
changeset 12 ead02e4e4806
parent 0 20e4ed35fd3f
permissions -rw-r--r--
write .branch.txt to make the new head

package junit.extensions;

import junit.framework.Protectable;
import junit.framework.Test;
import junit.framework.TestResult;

/**
 * A Decorator to set up and tear down additional fixture state. Subclass
 * TestSetup and insert it into your tests when you want to set up additional
 * state once before the tests are run.
 */
public class TestSetup extends TestDecorator {

	public TestSetup(Test test) {
		super(test);
	}

	@Override
	public void run(final TestResult result) {
		Protectable p= new Protectable() {
			public void protect() throws Exception {
				setUp();
				basicRun(result);
				tearDown();
			}
		};
		result.runProtected(this, p);
	}

	/**
	 * Sets up the fixture. Override to set up additional fixture state.
	 */
	protected void setUp() throws Exception {
	}

	/**
	 * Tears down the fixture. Override to tear down the additional fixture
	 * state.
	 */
	protected void tearDown() throws Exception {
	}
}