1 54 55 package junitx.framework; 56 57 import junit.framework.Test; 58 59 70 public class OrderedTestSuite 71 extends TestSuite { 72 73 76 public OrderedTestSuite() { 77 super(); 78 } 79 80 86 public OrderedTestSuite(final Class theClass) { 87 super(theClass); 88 } 89 90 93 public OrderedTestSuite(String name) { 94 super(name); 95 } 96 97 101 public void addTest(Test test) { 102 fTests.add(test); 103 sortTests(0, fTests.size() - 1); 104 } 105 106 protected void sortTests(int left, int right) { 107 int oleft = left; 108 int oright = right; 109 String mid = ((Test) this.fTests.get((left + right) / 2)).toString(); 110 do { 111 while ((((Test) this.fTests.get(left)).toString()).compareTo(mid) < 0) { 112 left++; 113 } 114 while (mid.compareTo(((Test) this.fTests.get(right)).toString()) < 0) { 115 right--; 116 } 117 if (left <= right) { 118 Object tmp = this.fTests.get(left); 119 this.fTests.set(left, this.fTests.get(right)); 120 this.fTests.set(right, tmp); 121 122 left++; 123 right--; 124 } 125 } while (left <= right); 126 127 if (oleft < right) { 128 sortTests(oleft, right); 129 } 130 if (left < oright) { 131 sortTests(left, oright); 132 } 133 } 134 135 } 136 | Popular Tags |