Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 109   Methods: 5
NCLOC: 85   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UnitTestSuite.java 0% 0% 0% 0%
coverage
 1   
 package abbot;
 2   
 
 3   
 import java.util.*;
 4   
 import java.io.File;
 5   
 import junit.framework.*;
 6   
 import junit.extensions.abbot.TestHelper;
 7   
 
 8   
 public class UnitTestSuite extends junit.framework.TestSuite {
 9   
 
 10  0
     private static TestSuite createSuite(Class cls) {
 11  0
         try {
 12  0
             java.lang.reflect.Method suiteMethod =
 13   
                 cls.getMethod("suite", null);
 14  0
             return (TestSuite)suiteMethod.invoke(null, null);
 15   
         }
 16   
         catch(Exception e) {
 17  0
             return new TestSuite(cls);
 18   
         }
 19   
     }
 20   
 
 21  0
     private static Collection findTestClasses(File file, String name) {
 22  0
         if ("test".equals(name))
 23  0
             return new ArrayList();
 24   
 
 25  0
         Set set = new HashSet();
 26  0
         File[] files = file.listFiles();
 27  0
         if (files == null) {
 28  0
             if (name.endsWith("Test.class")) {
 29  0
                 String className = name.substring(0, name.length()-6);
 30  0
                 try {
 31  0
                     Class cls = Class.forName(className);
 32  0
                     if (!set.contains(cls)) {
 33  0
                         set.add(cls);
 34   
                     }
 35   
                 }
 36   
                 catch(ClassNotFoundException e) {
 37  0
                     e.printStackTrace();
 38   
                 }
 39   
             }
 40   
         }
 41   
         else {
 42  0
             for (int i=0;i < files.length;i++) {
 43  0
                 Collection tests =
 44   
                     findTestClasses(files[i],
 45  0
                                     "".equals(name)
 46   
                                     ? files[i].getName()
 47   
                                     : name + "." + files[i].getName());
 48  0
                 set.addAll(tests);
 49   
             }
 50   
         }
 51  0
         return set;
 52   
     }
 53   
 
 54  0
     public static Test suite() {
 55  0
         String filter = System.getProperty("abbot.test.filter");
 56  0
         if (filter == null)
 57  0
             filter = "";
 58   
 
 59   
         // Any classes which should be run first or in some particular order
 60   
         // should be put here.  Otherwise test case suites are run in the
 61   
         // order the classes are added. 
 62  0
         Class[] priority = new Class[] {
 63   
             abbot.tester.WindowTrackerTest.class,
 64   
             junit.extensions.abbot.ComponentTestFixtureTest.class,
 65   
             junit.extensions.abbot.ScriptTestSuiteTest.class,
 66   
             abbot.tester.RobotTest.class,
 67   
         };
 68   
         // This group has some strange interactions...
 69   
         /*
 70   
           abbot.editor.ComponentBrowserTest.class, //
 71   
           abbot.editor.ComponentNodeTest.class, //
 72   
           abbot.editor.ComponentTreeTest.class, //
 73   
           abbot.editor.recorder.JInternalFrameRecorderTest.class, //
 74   
           abbot.finder.BasicFinderTest.class, //
 75   
           abbot.tester.JInternalFrameTesterTest.class, //
 76   
         */
 77   
         // Now add everything else
 78  0
         File file = new File(System.getProperty("user.dir")
 79   
                              + File.separator + "build"
 80   
                              + File.separator + "test-classes");
 81  0
         TestSuite suite = new TestSuite();
 82  0
         Set scanned = new HashSet();
 83  0
         scanned.addAll(findTestClasses(file, ""));
 84   
 
 85  0
         for (int i=0;i < priority.length;i++) {
 86  0
             Class cls = priority[i];
 87  0
             if (scanned.contains(cls)
 88   
                 && cls.getName().indexOf(filter) != -1) {
 89  0
                 suite.addTest(createSuite(cls));
 90   
             }
 91   
         }
 92  0
         scanned.removeAll(Arrays.asList(priority));
 93  0
         Iterator iter = scanned.iterator();
 94  0
         while (iter.hasNext()) {
 95  0
             Class cls = (Class)iter.next();
 96  0
             if (cls.getName().indexOf(filter) != -1) {
 97  0
                 suite.addTest(createSuite(cls));
 98   
             }
 99   
         }
 100  0
         return suite;
 101   
     }
 102   
 
 103  0
     public UnitTestSuite(String name) { super(name); }
 104   
 
 105  0
     public static void main(String[] args) {
 106  0
         TestHelper.runTests(args, UnitTestSuite.class);
 107   
     }
 108   
 }
 109