diff options
Diffstat (limited to 'tests')
3 files changed, 46 insertions, 9 deletions
diff --git a/tests/junit-runner/JunitLikeXmlOutputListener.java b/tests/junit-runner/JunitLikeXmlOutputListener.java index 24cfb30..5e39cf6 100644 --- a/tests/junit-runner/JunitLikeXmlOutputListener.java +++ b/tests/junit-runner/JunitLikeXmlOutputListener.java @@ -20,10 +20,12 @@ import java.util.HashMap; 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 @@ public class JunitLikeXmlOutputListener extends RunListener { testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString()); } KnownToFail k2f = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFail.class); + boolean thisTestIsK2F = false; Remote remote = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), Remote.class); if (k2f != null) { - testcaseAtts.put(K2F, Boolean.TRUE.toString()); + //determine if k2f in the current browser + //?? + Browsers[] br = k2f.failsIn(); + if(0 == br.length){//the KnownToFail annotation without optional parameter + thisTestIsK2F = true; + }else{ + for(Browsers b : br){ + if(description.toString().contains(b.toString())){ + thisTestIsK2F = true; + } + } + } } + if( thisTestIsK2F ) 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 (thisTestIsK2F) { failedK2F++; } Map<String, String> errorAtts = new HashMap<String, String>(3); @@ -226,7 +241,7 @@ public class JunitLikeXmlOutputListener extends RunListener { writeElement(TEST_ERROR_ELEMENT, testFailed.getTrace(), errorAtts); } else { - if (k2f != null) { + if (thisTestIsK2F) { if (ignored) { ignoredK2F++; } else { @@ -265,25 +280,25 @@ public class JunitLikeXmlOutputListener extends RunListener { classStats.put(description.getClassName(), classStat); } classStat.total++; - if (k2f != null) { + if (thisTestIsK2F) { classStat.totalK2F++; } classStat.time += testTime; if (testFailed == null) { if (ignored) { classStat.ignored++; - if (k2f != null) { + if (thisTestIsK2F) { classStat.ignoredK2F++; } } else { classStat.passed++; - if (k2f != null) { + if (thisTestIsK2F) { classStat.passedK2F++; } } } else { classStat.failed++; - if (k2f != null) { + if (thisTestIsK2F) { classStat.failedK2F++; } } diff --git a/tests/junit-runner/LessVerboseTextListener.java b/tests/junit-runner/LessVerboseTextListener.java index e660157..34df9f3 100644 --- a/tests/junit-runner/LessVerboseTextListener.java +++ b/tests/junit-runner/LessVerboseTextListener.java @@ -10,6 +10,7 @@ import java.lang.annotation.Annotation; 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,7 +75,22 @@ public class LessVerboseTextListener extends RunListener { private void printK2F(PrintStream writer, Boolean failed, Description description) { try { KnownToFail k2f = getK2F(description); - if (k2f != null) { + boolean thisTestIsK2F = 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={} + thisTestIsK2F = true; + }else{ + for(Browsers b : br){ + if(description.toString().contains(b.toString())){ + thisTestIsK2F = true; + } + } + } + } + + if( thisTestIsK2F ){ totalK2F++; if (failed != null) { if (failed) { diff --git a/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java b/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFail.java index 15e7e87..0d46de0 100644 --- 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.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import net.sourceforge.jnlp.browsertesting.Browsers; /** * <p> @@ -52,10 +53,15 @@ import java.lang.annotation.Target; * This annotation is meant for adding tests for bugs before the fix is * implemented. * </p> + * <p> + * 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. + * </p> */ @Target({ElementType.METHOD,ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface KnownToFail { - + public Browsers[] failsIn() default {}; } |