Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 72   Methods: 5
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ScriptFixture.java 100% 53.8% 60% 60%
coverage coverage
 1   
 package junit.extensions.abbot;
 2   
 
 3   
 import junit.framework.TestCase;
 4   
 
 5   
 import abbot.Log;
 6   
 import abbot.script.*;
 7   
 import abbot.util.AWTFixtureHelper;
 8   
 import abbot.finder.*;
 9   
 
 10   
 /** Simple wrapper for a test script to run under JUnit.  If the script
 11   
  * does not contain a launch step, the hierarchy used will include existing
 12   
  * components.  No automatic cleanup of components is performed, since it is
 13   
  * assumed that a Terminate step within the script will trigger that operation
 14   
  * if it is required.<p>
 15   
  */
 16   
 public class ScriptFixture extends TestCase {
 17   
 
 18   
     private static AWTFixtureHelper oldContext = null;
 19   
     private static final Hierarchy DUMMY_HIERARCHY = new AWTHierarchy();
 20   
     private StepRunner runner;
 21   
     
 22   
     /** Construct a test case with the given name, which <i>must</i> be the
 23   
      * filename of the script to run.
 24   
      */
 25  12
     public ScriptFixture(String filename) { 
 26   
         // It is essential that the name be passed to super() unmodified, or
 27   
         // the JUnit GUI will consider it a different test.
 28  12
         super(filename);
 29   
     }
 30   
 
 31   
     /** Saves the current UI state for restoration when the
 32   
         fixture (if any) is terminated.  Also sets up a 
 33   
         {@link TestHierarchy} for the duration of the test.
 34   
     */
 35  12
     protected void setUp() throws Exception {
 36  12
         if (oldContext == null) {
 37  1
             oldContext = new AWTFixtureHelper();
 38   
         }
 39  12
         runner = new StepRunner(oldContext);
 40   
         // Support for deprecated ComponentTester.assertFrameShowing usage
 41   
         // only.  Eventually this will go away.
 42  12
         AWTHierarchy.setDefault(runner.getHierarchy());
 43   
     }
 44   
 
 45  12
     protected void tearDown() throws Exception {
 46  12
         AWTHierarchy.setDefault(null);
 47  12
         runner = null;
 48   
     }
 49   
 
 50   
     /** Override the default TestCase runTest method to invoke the script.
 51   
         The {@link Script} is created and a default {@link StepRunner} is used
 52   
         to run it.
 53   
         @see junit.framework.TestCase#runTest
 54   
      */
 55  0
     protected void runTest() throws Throwable {
 56  0
         Script script = new Script(getName(), DUMMY_HIERARCHY);
 57  0
         Log.log("Running " + script + " with " + getClass());
 58   
 
 59  0
         try {
 60  0
             runner.run(script);
 61   
         }
 62   
         finally {
 63  0
             Log.log(script.toString() + " finished");
 64   
         }
 65   
     }
 66   
 
 67   
     /** Assumes each argument is an Abbot script.  Runs each one. */
 68  0
     public static void main(String[] args) {
 69  0
         ScriptTestSuite.main(args);
 70   
     }
 71   
 }
 72