Annotation Type Broken


  • @Documented
    @Target({METHOD,CONSTRUCTOR,TYPE})
    @Retention(RUNTIME)
    @Test
    @Tag("broken")
    public @interface Broken
    If you want to mark JUnit tests which does not work for the moment as "broken" you can use this annotation. The tests will be skipped if you run JUnit. You can also add a date till when you want to fix this "broken" test. If the date is reached then the test will fail if it is not fixed (and the @Broken removed).

    You can also use this annotation to mark a method or constructor as "broken". If assertions are enabled an AssertionError will be thrown if you call such a broken method. If not only a error message will be logged.

    What is the difference to @SkipTestOn? "Broken" means, the test does not work for the moment and should be (temporarily) skipped. "SkipTestOn" means, this test is not constructed for that platform and should be therefore skipped on it.

    Since:
    23.11.2009
    Author:
    oliver
    See Also:
    SkipTestOn
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean hide
      Normally a test would be listed as "ignore" if it is marked as broken.
      java.lang.String[] host
      With this attribute you can express that the test is broken for the given host(s).
      java.lang.String[] javaVendor
      The test is broken for a special vendor VM?
      java.lang.String[] javaVersion
      You want to mark the test as broken on a special version of the VM, e.g.
      java.lang.String[] osArch
      The test is broken only for the Intel architecture?
      java.lang.String[] osName
      Should a test be skipped on a single platform e.g. for Linux?
      java.lang.String[] osVersion
      The test breaks only on a special version of the operating system?
      java.lang.String[] property
      You have some tests that are broken if some proxy properties are set?
      java.lang.String since
      Use this attribute to mark the begin of the broken area, when it was detected that your JUnit test or method does not work as expected.
      java.lang.String till
      Use this attribute till you want the broken JUnit test to be fixed.
      java.lang.String[] user
      Does the test break only for user "Bob" and you can't fix it for him at the moment?
      java.lang.String value
      You can change the default string to give a reason why the test is marked as "broken".
      java.lang.String why
      You can change the default string to give a reason why the test is marked as "broken".
    • Element Detail

      • value

        java.lang.String value
        You can change the default string to give a reason why the test is marked as "broken". You can use 'value=...' or 'wyh=...' to change it.
        Returns:
        the string
        Default:
        "marked as @Broken"
      • why

        java.lang.String why
        You can change the default string to give a reason why the test is marked as "broken". You can use 'value=...' or 'why=...' to change it.
        Returns:
        the string
        Default:
        ""
      • since

        java.lang.String since
        Use this attribute to mark the begin of the broken area, when it was detected that your JUnit test or method does not work as expected.

        The format of the date is "dd-MMM-yyyy".

        Returns:
        the string
        Default:
        ""
      • till

        java.lang.String till
        Use this attribute till you want the broken JUnit test to be fixed.

        The format of the date is "dd-MMM-yyyy" or "dd-MMM-yyyy H:mm".

        Returns:
        the string
        Default:
        ""
      • user

        java.lang.String[] user
        Does the test break only for user "Bob" and you can't fix it for him at the moment? Use user="bob" to mark it as broken for user account "bob".

        Damn, the new member of the team, Bill, has the same problem and nobody is able to fix it. Ok, use user={"bob", "bill"} to mark the code as broken for both user.

        Returns:
        the string[]
        Since:
        1.0
        Default:
        {""}
      • osName

        java.lang.String[] osName
        Should a test be skipped on a single platform e.g. for Linux? Use "Linux" to mark it as broken only for the Linux platform. Instead of "Linux" you can use any other operation system. The format must be the same as returned by the system property "os.name". Valid values are:
        • "Linux"
        • "Mac OS X" (for Mac),
        • "Windows XP"
        • and others (see http://lopica.sourceforge.net/os.html).

        Multiple values like { "Linux", "Mac OS X" } are allowed. If no operation system is given you will get an IllegalArgumentException.

        The format of this attribute must be the same as returned by system property "os.name".

        Note: this attribute replaces the old 'os' attribute which was removed in 1.6.

        Returns:
        the string[]
        Since:
        1.1
        Default:
        {""}
      • osArch

        java.lang.String[] osArch
        The test is broken only for the Intel architecture? Then you can use this attribute to limit it on this platform. You can define a single platform like "x86_64" for an Intel-Mac with 64 bit or multiple platform like { "x86_32", "x86_64" } for Intel Mac with 42 or 64 bit.

        The format of this attribute must be the same as returned by the system property "os.arch".

        Returns:
        the string[]
        Since:
        1.1
        Default:
        {""}
      • osVersion

        java.lang.String[] osVersion
        The test breaks only on a special version of the operating system? Use this attribute to limit it. In contradiction to the other attributes the real version must start with the given version. I.e. if you define "10.6" as version this would match only real version "10.6.1" or "10.6.2".

        You can't define a range of skipped versions. But several versions are allowed. So if you want to skip the tests in version 10.6.1 till 10.6.3 define { "10.6.1", "10.6.2", "10.6.3" } as values. The format of this attribute must be the same as returned by the system property "osVersion".

        Returns:
        the string[]
        Since:
        1.1
        Default:
        {""}
      • host

        java.lang.String[] host
        With this attribute you can express that the test is broken for the given host(s). Perhaps these hosts have not enough memory. You can define the host by its name or by its IP address.
        Returns:
        the string[]
        Since:
        1.1
        Default:
        {""}
      • javaVersion

        java.lang.String[] javaVersion
        You want to mark the test as broken on a special version of the VM, e.g. on version "1.6.0_17" because you know that on this version there is a bug that caused your test not to work? Then use this attribute.

        You can't define a range of skipped versions. But you regex (regular expressions) are allowed. And you can define more than one version (or regex).

        The format of this attribute must be the same as returned by the system property "java.version".

        Returns:
        the string[]
        Since:
        1.1
        Default:
        {""}
      • javaVendor

        java.lang.String[] javaVendor
        The test is broken for a special vendor VM? Use this attribute here. The format of this attribute must be the same as returned by the system property "java.vendor". Valid values are:
        • "Apple Inc."
        • and others
        Returns:
        the string[]
        Since:
        1.1
        Default:
        {""}
      • property

        java.lang.String[] property
        You have some tests that are broken if some proxy properties are set? Define the property here (e.g. property="proxy.host"). If this property is set (and its value is not "false") the test will be skipped if this property is set as system property.

        You can control more than property with this attribute. Then all properties must be "true" to skip the test.

        Returns:
        the string[]
        Since:
        1.1
        Default:
        {""}
      • hide

        boolean hide
        Normally a test would be listed as "ignore" if it is marked as broken. If you must pass some quality gates which do not allow ignored tests (e.g. if you use Sonar that can be a quality gate) fix the bug and remove the Broken annotation.

        Nevertheless you can set this flag to true. This can be useful if you want to fix the bug in a later release but must pass now some quality gates.

        NOTE: Because of limitations of JUnit and the RemoteTestRunner of Eclipse this flag not supported at class level, only on method level. If you'll try to set in on class level you will get an UnsupportedOperationException at runtime.

        Returns:
        true, if successful
        Since:
        1.7
        Default:
        false