carbidecpp20devenv/plugins/org.eclipse.test.source_3.3.0.v20080507/src/org.junit4_4.3.1/junitsrc/junit/extensions/TestSetup.java
changeset 1 82d1d1de1a01
equal deleted inserted replaced
-1:000000000000 1:82d1d1de1a01
       
     1 package junit.extensions;
       
     2 
       
     3 import junit.framework.Protectable;
       
     4 import junit.framework.Test;
       
     5 import junit.framework.TestResult;
       
     6 
       
     7 /**
       
     8  * A Decorator to set up and tear down additional fixture state. Subclass
       
     9  * TestSetup and insert it into your tests when you want to set up additional
       
    10  * state once before the tests are run.
       
    11  */
       
    12 public class TestSetup extends TestDecorator {
       
    13 
       
    14 	public TestSetup(Test test) {
       
    15 		super(test);
       
    16 	}
       
    17 
       
    18 	@Override
       
    19 	public void run(final TestResult result) {
       
    20 		Protectable p= new Protectable() {
       
    21 			public void protect() throws Exception {
       
    22 				setUp();
       
    23 				basicRun(result);
       
    24 				tearDown();
       
    25 			}
       
    26 		};
       
    27 		result.runProtected(this, p);
       
    28 	}
       
    29 
       
    30 	/**
       
    31 	 * Sets up the fixture. Override to set up additional fixture state.
       
    32 	 */
       
    33 	protected void setUp() throws Exception {
       
    34 	}
       
    35 
       
    36 	/**
       
    37 	 * Tears down the fixture. Override to tear down the additional fixture
       
    38 	 * state.
       
    39 	 */
       
    40 	protected void tearDown() throws Exception {
       
    41 	}
       
    42 }