001package junit.extensions; 002 003import junit.framework.Assert; 004import junit.framework.Test; 005import junit.framework.TestResult; 006 007/** 008 * A Decorator for Tests. Use TestDecorator as the base class for defining new 009 * test decorators. Test decorator subclasses can be introduced to add behaviour 010 * before or after a test is run. 011 */ 012@SuppressWarnings("deprecation") 013public class TestDecorator extends Assert implements Test { 014 protected Test fTest; 015 016 public TestDecorator(Test test) { 017 fTest = test; 018 } 019 020 /** 021 * The basic run behaviour. 022 */ 023 public void basicRun(TestResult result) { 024 fTest.run(result); 025 } 026 027 public int countTestCases() { 028 return fTest.countTestCases(); 029 } 030 031 public void run(TestResult result) { 032 basicRun(result); 033 } 034 035 @Override 036 public String toString() { 037 return fTest.toString(); 038 } 039 040 public Test getTest() { 041 return fTest; 042 } 043}