| 1 | /* |
| 2 | * Copyright 2015-2024 the original author or authors. |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials are |
| 5 | * made available under the terms of the Eclipse Public License v2.0 which |
| 6 | * accompanies this distribution and is available at |
| 7 | * |
| 8 | * https://www.eclipse.org/legal/epl-v20.html |
| 9 | */ |
| 10 | |
| 11 | package org.junit.jupiter.api; |
| 12 | |
| 13 | import static org.apiguardian.api.API.Status.STABLE; |
| 14 | |
| 15 | import java.lang.annotation.Documented; |
| 16 | import java.lang.annotation.ElementType; |
| 17 | import java.lang.annotation.Retention; |
| 18 | import java.lang.annotation.RetentionPolicy; |
| 19 | import java.lang.annotation.Target; |
| 20 | |
| 21 | import org.apiguardian.api.API; |
| 22 | |
| 23 | /** |
| 24 | * {@code @Disabled} is used to signal that the annotated test class or |
| 25 | * test method is currently <em>disabled</em> and should not be executed. |
| 26 | * |
| 27 | * <p>{@code @Disabled} may optionally be declared with a {@linkplain #value |
| 28 | * reason} to document why the annotated test class or test method is disabled. |
| 29 | * |
| 30 | * <p>When applied at the class level, all test methods within that class |
| 31 | * are automatically disabled as well. |
| 32 | * |
| 33 | * <p>This annotation is not {@link java.lang.annotation.Inherited @Inherited}. |
| 34 | * Consequently, if you wish to apply the same semantics to a subclass, this |
| 35 | * annotation must be redeclared on the subclass. |
| 36 | * |
| 37 | * <p>When applied at the method level, the presence of this annotation does not |
| 38 | * prevent the test class from being instantiated. Rather, it prevents the |
| 39 | * execution of the test method and method-level lifecycle callbacks such as |
| 40 | * {@code @BeforeEach} methods, {@code @AfterEach} methods, and corresponding |
| 41 | * extension APIs. |
| 42 | * |
| 43 | * @since 5.0 |
| 44 | * @see #value |
| 45 | * @see org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable |
| 46 | * @see org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable |
| 47 | * @see org.junit.jupiter.api.condition.EnabledIfSystemProperty |
| 48 | * @see org.junit.jupiter.api.condition.DisabledIfSystemProperty |
| 49 | * @see org.junit.jupiter.api.condition.EnabledOnJre |
| 50 | * @see org.junit.jupiter.api.condition.DisabledOnJre |
| 51 | * @see org.junit.jupiter.api.condition.EnabledForJreRange |
| 52 | * @see org.junit.jupiter.api.condition.DisabledForJreRange |
| 53 | * @see org.junit.jupiter.api.condition.EnabledOnOs |
| 54 | * @see org.junit.jupiter.api.condition.DisabledOnOs |
| 55 | * @see org.junit.jupiter.api.condition.EnabledInNativeImage |
| 56 | * @see org.junit.jupiter.api.condition.DisabledInNativeImage |
| 57 | * @see org.junit.jupiter.api.extension.ExecutionCondition |
| 58 | */ |
| 59 | @Target({ ElementType.TYPE, ElementType.METHOD }) |
| 60 | @Retention(RetentionPolicy.RUNTIME) |
| 61 | @Documented |
| 62 | @API(status = STABLE, since = "5.0") |
| 63 | public @interface Disabled { |
| 64 | |
| 65 | /** |
| 66 | * The reason this annotated test class or test method is disabled. |
| 67 | */ |
| 68 | String value() default ""; |
| 69 | |
| 70 | } |