Annotation Type Testable


  • @Target({TYPE,METHOD})
    @Retention(RUNTIME)
    @Inherited
    @Documented
    @API(status=STABLE,
         since="1.0")
    public @interface Testable
    @Testable is used to signal to IDEs and tooling vendors that the annotated or meta-annotated element is testable.

    In this context, the term "testable" means that the annotated method or class can be executed by a TestEngine as a test or test container on the JUnit Platform.

    Motivation for @Testable

    Some clients of the JUnit Platform, notably IDEs such as IntelliJ IDEA, operate only on sources for test discovery. Thus, they cannot use the full runtime discovery mechanism of the JUnit Platform since it relies on compiled classes. @Testable therefore serves as an alternative mechanism for IDEs to discover tests by analyzing the source code only.

    Common Use Cases

    @Testable will typically be used as a meta-annotation in order to create a custom composed annotation that inherits the semantics of @Testable. For example, the @Test and @TestFactory annotations in JUnit Jupiter are meta-annotated with @Testable.

    For test programming models that do not rely on annotations, test classes or test methods may be directly annotated with @Testable. Alternatively, if concrete test classes extend from a base class, the base class can be annotated with @Testable. Note that @Testable is an @Inherited annotation.

    Requirements for IDEs and Tooling Vendors

    • If a top-level class, static nested class, or inner class is not annotated or meta-annotated with @Testable but contains a method that is annotated or meta-annotated with @Testable, the class must be considered to be a testable class.
    • If annotation hierarchies containing @Testable are present on classes or methods in compiled byte code (e.g., in JARs in the user's classpath), IDEs and tooling vendors must also take such annotation hierarchies into consideration when performing annotation processing for source code.

    Restrictions for TestEngine Implementations

    A TestEngine must not in any way perform discovery based on the presence of @Testable. In terms of discovery, the presence of @Testable should only be meaningful to clients such as IDEs and tooling vendors. A TestEngine implementation is therefore required to discover tests based on information specific to that test engine (e.g., annotations specific to that test engine).

    Since:
    1.0