Changeset 429 for trunk/icedtea-web/tests/junit-runner
- Timestamp:
- Sep 24, 2014, 9:34:21 PM (11 years ago)
- Location:
- trunk/icedtea-web/tests/junit-runner
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/icedtea-web/tests/junit-runner/CommandLine.java
r418 r429 27 27 public static void runMainAndExit(JUnitSystem system, String... args) { 28 28 new CommandLine().runMain(system, args); 29 system.exit(0);29 System.exit(0); 30 30 } 31 31 32 @Override33 32 public Result runMain(JUnitSystem system, String... args) { 34 33 List<Class<?>> classes = new ArrayList<Class<?>>(); … … 47 46 RunListener listener = new LessVerboseTextListener(system); 48 47 addListener(listener); 49 Result result = run(classes.toArray(new Class [0]));48 Result result = run(classes.toArray(new Class<?>[0])); 50 49 for (Failure each : missingClasses) { 51 50 result.getFailures().add(each); -
trunk/icedtea-web/tests/junit-runner/JunitLikeXmlOutputListener.java
r418 r429 21 21 import java.util.Map.Entry; 22 22 import java.util.Set; 23 import java.util.Arrays; 23 24 import java.util.concurrent.TimeUnit; 24 25 import net.sourceforge.jnlp.annotations.Bug; 25 26 import net.sourceforge.jnlp.annotations.KnownToFail; 27 import net.sourceforge.jnlp.annotations.Remote; 28 import net.sourceforge.jnlp.browsertesting.Browsers; 26 29 27 30 … … 50 53 private static final String BUG = "bug"; 51 54 private static final String K2F = "known-to-fail"; 55 private static final String REMOTE = "remote"; 52 56 private static final String TEST_NAME_ATTRIBUTE = "name"; 53 57 private static final String TEST_TIME_ATTRIBUTE = "time"; … … 77 81 private class ClassStat { 78 82 79 Class c;83 Class<?> c; 80 84 int total; 81 85 int failed; … … 173 177 testDone(description, testTime, testTimeSeconds, false); 174 178 } 175 179 180 181 @SuppressWarnings("unchecked") 176 182 private void testDone(Description description, long testTime, double testTimeSeconds, boolean ignored) throws Exception { 177 Class testClass = null;183 Class<?> testClass = null; 178 184 Method testMethod = null; 179 185 try { … … 198 204 testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString()); 199 205 } 200 KnownToFail k2f=null; 201 try { 202 if (testClass != null && testMethod != null) { 203 k2f = testMethod.getAnnotation(KnownToFail.class); 204 if (k2f != null) { 205 testcaseAtts.put(K2F, Boolean.TRUE.toString()); 206 } 207 } 208 } catch (Exception ex) { 209 ex.printStackTrace(); 206 KnownToFail k2f = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFail.class); 207 boolean thisTestIsK2F = false; 208 Remote remote = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), Remote.class); 209 if (k2f != null) { 210 //determine if k2f in the current browser 211 //?? 212 Browsers[] br = k2f.failsIn(); 213 if(0 == br.length){//the KnownToFail annotation without optional parameter 214 thisTestIsK2F = true; 215 }else{ 216 for(Browsers b : br){ 217 if(description.toString().contains(b.toString())){ 218 thisTestIsK2F = true; 219 } 220 } 221 } 222 } 223 if( thisTestIsK2F ) testcaseAtts.put(K2F, Boolean.TRUE.toString()); 224 if (remote != null) { 225 testcaseAtts.put(REMOTE, Boolean.TRUE.toString()); 226 210 227 } 211 228 openElement(TEST_ELEMENT, testcaseAtts); 212 229 if (testFailed != null) { 213 if ( k2f != null) {230 if (thisTestIsK2F) { 214 231 failedK2F++; 215 232 } … … 226 243 writeElement(TEST_ERROR_ELEMENT, testFailed.getTrace(), errorAtts); 227 244 } else { 228 if ( k2f != null) {245 if (thisTestIsK2F) { 229 246 if (ignored) { 230 247 ignoredK2F++; … … 265 282 } 266 283 classStat.total++; 267 if ( k2f != null) {284 if (thisTestIsK2F) { 268 285 classStat.totalK2F++; 269 286 } … … 272 289 if (ignored) { 273 290 classStat.ignored++; 274 if ( k2f != null) {291 if (thisTestIsK2F) { 275 292 classStat.ignoredK2F++; 276 293 } 277 294 } else { 278 295 classStat.passed++; 279 if ( k2f != null) {296 if (thisTestIsK2F) { 280 297 classStat.passedK2F++; 281 298 } … … 283 300 } else { 284 301 classStat.failed++; 285 if ( k2f != null) {302 if (thisTestIsK2F) { 286 303 classStat.failedK2F++; 287 304 } … … 290 307 291 308 @Override 309 @SuppressWarnings("unchecked") 292 310 public void testRunFinished(Result result) throws Exception { 293 311 … … 320 338 Bug b = null; 321 339 if (entry.getValue().c != null) { 322 b = (Bug)entry.getValue().c.getAnnotation(Bug.class);340 b = entry.getValue().c.getAnnotation(Bug.class); 323 341 } 324 342 if (b != null) { -
trunk/icedtea-web/tests/junit-runner/LessVerboseTextListener.java
r418 r429 7 7 */ 8 8 import java.io.PrintStream; 9 import java.lang.annotation.Annotation; 9 10 import java.lang.reflect.Method; 10 11 import net.sourceforge.jnlp.annotations.KnownToFail; 12 import net.sourceforge.jnlp.annotations.Remote; 13 import net.sourceforge.jnlp.browsertesting.Browsers; 11 14 12 15 import org.junit.internal.JUnitSystem; … … 38 41 writer.println("Ignored: " + description.getClassName() + "." + description.getMethodName()); 39 42 printK2F(writer, null, description); 43 printRemote(writer, description); 40 44 } 41 45 … … 46 50 writer.println("FAILED: " + failure.getTestHeader() + " " + failure.getMessage()); 47 51 printK2F(writer,true,failure.getDescription()); 52 printRemote(writer, failure.getDescription()); 48 53 } 49 54 … … 53 58 writer.println("Passed: " + description.getClassName() + "." + description.getMethodName()); 54 59 printK2F(writer,false,description); 60 printRemote(writer, description); 55 61 } 56 62 } … … 70 76 try { 71 77 KnownToFail k2f = getK2F(description); 72 if (k2f != null) { 78 boolean thisTestIsK2F = false; 79 if (k2f != null){ 80 //determine if k2f in the current browser 81 Browsers[] br = k2f.failsIn(); 82 if(0 == br.length){ //@KnownToFail with default optional parameter failsIn={} 83 thisTestIsK2F = true; 84 }else{ 85 for(Browsers b : br){ 86 if(description.toString().contains(b.toString())){ 87 thisTestIsK2F = true; 88 } 89 } 90 } 91 } 92 93 if( thisTestIsK2F ){ 73 94 totalK2F++; 74 95 if (failed != null) { … … 94 115 } 95 116 96 public static KnownToFail getK2F(Description description) { 117 118 @SuppressWarnings("unchecked") 119 public static <T extends Annotation> T getAnnotation(Class<?> q, String methodName, Class<T> a) { 97 120 try { 98 Class q = description.getTestClass();99 121 if (q != null) { 100 String qs = description.getMethodName(); 122 T rem = q.getAnnotation(a); 123 if (rem != null) { 124 return rem; 125 } 126 String qs = methodName; 101 127 if (qs.contains(" - ")) { 102 128 qs = qs.replaceAll(" - .*", ""); … … 104 130 Method qm = q.getMethod(qs); 105 131 if (qm != null) { 106 KnownToFail k2f = qm.getAnnotation(KnownToFail.class);107 return k2f;132 rem = qm.getAnnotation(a); 133 return rem; 108 134 109 135 } … … 115 141 } 116 142 143 public static KnownToFail getK2F(Description description) { 144 return getAnnotation(description.getTestClass(), description.getMethodName(), KnownToFail.class); 145 } 146 147 public static Remote getRemote(Description description) { 148 return getAnnotation(description.getTestClass(), description.getMethodName(), Remote.class); 149 150 } 151 152 private void printRemote(PrintStream writer, Description description) { 153 try { 154 Remote rem = getRemote(description); 155 if (rem != null) { 156 writer.println(" - This test is running remote content, note that failures may be caused by broken target application or connection"); 157 } 158 } catch (Exception ex) { 159 ex.printStackTrace(); 160 } 161 } 117 162 }
Note:
See TracChangeset
for help on using the changeset viewer.