Debian Codegraph @

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ExecutionCondition.java

raw symbols SCIP
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.extension;
12
13 import static org.apiguardian.api.API.Status.STABLE;
14
15 import org.apiguardian.api.API;
16
17 /**
18 * {@code ExecutionCondition} defines the {@link Extension} API for
19 * programmatic, <em>conditional test execution</em>.
20 *
21 * <p>An {@code ExecutionCondition} is
22 * {@linkplain #evaluateExecutionCondition(ExtensionContext) evaluated}
23 * to determine if a given container or test should be executed based on the
24 * supplied {@link ExtensionContext}.
25 *
26 * <p>If an {@code ExecutionCondition} {@linkplain ConditionEvaluationResult#disabled
27 * disables} a test method, that does not prevent the test class from being
28 * instantiated. Rather, it prevents the execution of the test method and
29 * method-level lifecycle callbacks such as {@code @BeforeEach} methods,
30 * {@code @AfterEach} methods, and corresponding extension APIs.
31 *
32 * <h2>Constructor Requirements</h2>
33 *
34 * <p>Consult the documentation in {@link Extension} for details on
35 * constructor requirements.
36 *
37 * @since 5.0
38 * @see org.junit.jupiter.api.Disabled
39 * @see org.junit.jupiter.api.condition.EnabledIf
40 * @see org.junit.jupiter.api.condition.DisabledIf
41 * @see org.junit.jupiter.api.condition.EnabledOnOs
42 * @see org.junit.jupiter.api.condition.DisabledOnOs
43 * @see org.junit.jupiter.api.condition.EnabledOnJre
44 * @see org.junit.jupiter.api.condition.DisabledOnJre
45 * @see org.junit.jupiter.api.condition.EnabledForJreRange
46 * @see org.junit.jupiter.api.condition.DisabledForJreRange
47 * @see org.junit.jupiter.api.condition.EnabledInNativeImage
48 * @see org.junit.jupiter.api.condition.DisabledInNativeImage
49 * @see org.junit.jupiter.api.condition.EnabledIfSystemProperty
50 * @see org.junit.jupiter.api.condition.DisabledIfSystemProperty
51 * @see org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable
52 * @see org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable
53 */
54 @FunctionalInterface
55 @API(status = STABLE, since = "5.0")
56 public interface ExecutionCondition extends Extension {
57
58 /**
59 * Evaluate this condition for the supplied {@link ExtensionContext}.
60 *
61 * <p>An {@linkplain ConditionEvaluationResult#enabled enabled} result
62 * indicates that the container or test should be executed; whereas, a
63 * {@linkplain ConditionEvaluationResult#disabled disabled} result
64 * indicates that the container or test should not be executed.
65 *
66 * @param context the current extension context; never {@code null}
67 * @return the result of evaluating this condition; never {@code null}
68 */
69 ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context);
70
71 }