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,13 @@ 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.KnownToFailInBrowsers; import net.sourceforge.jnlp.annotations.Remote; +import net.sourceforge.jnlp.browsertesting.Browsers; import org.junit.internal.JUnitSystem; @@ -201,17 +204,27 @@ testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString()); } KnownToFail k2f = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFail.class); + KnownToFailInBrowsers k2finB = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFailInBrowsers.class); + boolean knownToFailInThisBrowser = false; Remote remote = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), Remote.class); - if (k2f != null) { - testcaseAtts.put(K2F, Boolean.TRUE.toString()); - } + if (k2finB != null) { + //determine if k2f in the current browser + //?? + Browsers[] br = k2finB.failsIn(); + for(Browsers b : br){ + if(description.toString().contains(b.toString())){ + knownToFailInThisBrowser = true; + } + } + } + if( k2f != null || 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 (k2f != null || knownToFailInThisBrowser) { failedK2F++; } Map errorAtts = new HashMap(3); @@ -226,7 +239,7 @@ writeElement(TEST_ERROR_ELEMENT, testFailed.getTrace(), errorAtts); } else { - if (k2f != null) { + if (k2f != null || knownToFailInThisBrowser) { if (ignored) { ignoredK2F++; } else { @@ -265,25 +278,25 @@ classStats.put(description.getClassName(), classStat); } classStat.total++; - if (k2f != null) { + if (k2f != null || knownToFailInThisBrowser) { classStat.totalK2F++; } classStat.time += testTime; if (testFailed == null) { if (ignored) { classStat.ignored++; - if (k2f != null) { + if (k2f != null || knownToFailInThisBrowser) { classStat.ignoredK2F++; } } else { classStat.passed++; - if (k2f != null) { + if (k2f != null || knownToFailInThisBrowser) { classStat.passedK2F++; } } } else { classStat.failed++; - if (k2f != null) { + if (k2f != null || 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 @@ -9,7 +9,9 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import net.sourceforge.jnlp.annotations.KnownToFail; +import net.sourceforge.jnlp.annotations.KnownToFailInBrowsers; import net.sourceforge.jnlp.annotations.Remote; +import net.sourceforge.jnlp.browsertesting.Browsers; import org.junit.internal.JUnitSystem; import org.junit.runner.Description; @@ -74,24 +76,37 @@ 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"); - } + KnownToFailInBrowsers k2finB = getK2FinB(description); + + boolean knownToFailInThisBrowser = false; + if (k2finB != null){ + //determine if k2f in the current browser + Browsers[] br = k2finB.failsIn(); + for(Browsers b : br){ + if(description.toString().contains(b.toString())){ + knownToFailInThisBrowser = true; + } + } } + if( k2f != null || 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(); @@ -127,6 +142,10 @@ return (KnownToFail) getAnnotation(description.getTestClass(), description.getMethodName(), KnownToFail.class); } + public static KnownToFailInBrowsers getK2FinB(Description description) { + return (KnownToFailInBrowsers) getAnnotation(description.getTestClass(), description.getMethodName(), KnownToFailInBrowsers.class); + } + public static Remote getRemote(Description description) { return (Remote) getAnnotation(description.getTestClass(), description.getMethodName(), Remote.class); diff --git a/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFailInBrowsers.java b/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFailInBrowsers.java new file mode 100644 --- /dev/null +++ b/tests/test-extensions/net/sourceforge/jnlp/annotations/KnownToFailInBrowsers.java @@ -0,0 +1,65 @@ +/* KnownToFailInBrowsers.java +Copyright (C) 2013 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + +package net.sourceforge.jnlp.annotations; + +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; + +/** + *

+ * This annotation marks a test as a known failure (as opposed to a + * regression). A test that is a known failure will not hold of a release, + * nor should developers hold off a fix if they run the unit tests and a + * test marked as a known failure fails. + *

+ * This annotation is meant for adding tests for bugs before the fix is + * implemented. + *

+ *

Difference from annotation KnownToFail: testcase is known to fail + * only in given specific browsers. + *

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