diff --git a/tests/junit-runner/JunitLikeXmlOutputListener.java b/tests/junit-runner/JunitLikeXmlOutputListener.java --- a/tests/junit-runner/JunitLikeXmlOutputListener.java +++ b/tests/junit-runner/JunitLikeXmlOutputListener.java @@ -20,10 +20,12 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.Arrays; import java.util.concurrent.TimeUnit; import net.sourceforge.jnlp.annotations.Bug; import net.sourceforge.jnlp.annotations.KnownToFail; import net.sourceforge.jnlp.annotations.Remote; +import net.sourceforge.jnlp.browsertesting.Browsers; import org.junit.internal.JUnitSystem; @@ -201,17 +203,30 @@ testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString()); } KnownToFail k2f = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFail.class); + boolean knownToFailInThisBrowser = false; Remote remote = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), Remote.class); - if (k2f != null) { - testcaseAtts.put(K2F, Boolean.TRUE.toString()); - } + if (k2f != null) { + //determine if k2f in the current browser + + Browsers[] br = k2f.failsIn(); + if(0 == br.length){//the KnownToFail annotation without optional parameter + knownToFailInThisBrowser = true; + }else{ + for(Browsers b : br){ + if(description.toString().contains(b.toString())){ + knownToFailInThisBrowser = true; + } + } + } + } + if( knownToFailInThisBrowser ) testcaseAtts.put(K2F, Boolean.TRUE.toString()); if (remote != null) { testcaseAtts.put(REMOTE, Boolean.TRUE.toString()); } openElement(TEST_ELEMENT, testcaseAtts); if (testFailed != null) { - if (k2f != null) { + if (knownToFailInThisBrowser) { failedK2F++; } Map errorAtts = new HashMap(3); @@ -226,7 +241,7 @@ writeElement(TEST_ERROR_ELEMENT, testFailed.getTrace(), errorAtts); } else { - if (k2f != null) { + if (knownToFailInThisBrowser) { if (ignored) { ignoredK2F++; } else { @@ -265,25 +280,25 @@ classStats.put(description.getClassName(), classStat); } classStat.total++; - if (k2f != null) { + if (knownToFailInThisBrowser) { classStat.totalK2F++; } classStat.time += testTime; if (testFailed == null) { if (ignored) { classStat.ignored++; - if (k2f != null) { + if (knownToFailInThisBrowser) { classStat.ignoredK2F++; } } else { classStat.passed++; - if (k2f != null) { + if (knownToFailInThisBrowser) { classStat.passedK2F++; } } } else { classStat.failed++; - if (k2f != null) { + if (knownToFailInThisBrowser) { classStat.failedK2F++; } } diff --git a/tests/junit-runner/LessVerboseTextListener.java b/tests/junit-runner/LessVerboseTextListener.java --- a/tests/junit-runner/LessVerboseTextListener.java +++ b/tests/junit-runner/LessVerboseTextListener.java @@ -10,6 +10,7 @@ import java.lang.reflect.Method; import net.sourceforge.jnlp.annotations.KnownToFail; import net.sourceforge.jnlp.annotations.Remote; +import net.sourceforge.jnlp.browsertesting.Browsers; import org.junit.internal.JUnitSystem; import org.junit.runner.Description; @@ -74,24 +75,39 @@ private void printK2F(PrintStream writer, Boolean failed, Description description) { try { KnownToFail k2f = getK2F(description); - if (k2f != null) { - totalK2F++; - if (failed != null) { - if (failed) { - failedK2F++; - } else { - passedK2F++; - } - } else { - ignoredK2F++; - } - if (failed != null && !failed) { - writer.println(" - WARNING This test is known to fail, but have passed!"); - } else { - writer.println(" - This test is known to fail"); - } + boolean knownToFailInThisBrowser = false; + if (k2f != null){ + //determine if k2f in the current browser + Browsers[] br = k2f.failsIn(); + if(0 == br.length){ //@KnownToFail with default optional parameter failsIn={} + knownToFailInThisBrowser = true; + }else{ + for(Browsers b : br){ + if(description.toString().contains(b.toString())){ + knownToFailInThisBrowser = true; + } + } + } } + if( knownToFailInThisBrowser ){ + totalK2F++; + if (failed != null) { + if (failed) { + failedK2F++; + } else { + passedK2F++; + } + } else { + ignoredK2F++; + } + if (failed != null && !failed) { + writer.println(" - WARNING This test is known to fail, but have passed!"); + } else { + writer.println(" - This test is known to fail"); + } + } + } catch (Exception ex) { ex.printStackTrace(); diff --git a/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java b/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java --- a/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java +++ b/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java @@ -41,6 +41,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import net.sourceforge.jnlp.browsertesting.Browsers; /** *

@@ -52,10 +53,15 @@ * This annotation is meant for adding tests for bugs before the fix is * implemented. *

+ *

+ * The meaning of optional parameter failsIn is either a list of + * browsers where the test fails, or a default value - an empty array {}, + * default value means that the test fails always. + *

*/ @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface KnownToFail { - + public Browsers[] failsIn() default {}; }