Debian Codegraph @

junit-jupiter-api/src/main/java/org/junit/jupiter/api/Test.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;
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 import org.junit.platform.commons.annotation.Testable;
23
24 /**
25 * {@code @Test} is used to signal that the annotated method is a
26 * <em>test</em> method.
27 *
28 * <p>{@code @Test} methods must not be {@code private} or {@code static}
29 * and must not return a value.
30 *
31 * <p>{@code @Test} methods may optionally declare parameters to be
32 * resolved by {@link org.junit.jupiter.api.extension.ParameterResolver
33 * ParameterResolvers}.
34 *
35 * <p>{@code @Test} may also be used as a meta-annotation in order to create
36 * a custom <em>composed annotation</em> that inherits the semantics of
37 * {@code @Test}.
38 *
39 * <h2>Test Execution Order</h2>
40 *
41 * <p>By default, test methods will be ordered using an algorithm that is
42 * deterministic but intentionally nonobvious. This ensures that subsequent runs
43 * of a test suite execute test methods in the same order, thereby allowing for
44 * repeatable builds. In this context, a <em>test method</em> is any instance
45 * method that is directly annotated or meta-annotated with {@code @Test},
46 * {@code @RepeatedTest}, {@code @ParameterizedTest}, {@code @TestFactory}, or
47 * {@code @TestTemplate}.
48 *
49 * <p>Although true <em>unit tests</em> typically should not rely on the order
50 * in which they are executed, there are times when it is necessary to enforce
51 * a specific test method execution order &mdash; for example, when writing
52 * <em>integration tests</em> or <em>functional tests</em> where the sequence of
53 * the tests is important, especially in conjunction with
54 * {@link TestInstance @TestInstance(Lifecycle.PER_CLASS)}.
55 *
56 * <p>To control the order in which test methods are executed, annotate your
57 * test class or test interface with {@link TestMethodOrder @TestMethodOrder}
58 * and specify the desired {@link MethodOrderer} implementation.
59 *
60 * @since 5.0
61 * @see RepeatedTest
62 * @see org.junit.jupiter.params.ParameterizedTest
63 * @see TestTemplate
64 * @see TestFactory
65 * @see TestInfo
66 * @see DisplayName
67 * @see Tag
68 * @see BeforeAll
69 * @see AfterAll
70 * @see BeforeEach
71 * @see AfterEach
72 */
73 @Target({ ElementType.ANNOTATION_TYPE, ElementType.METHOD })
74 @Retention(RetentionPolicy.RUNTIME)
75 @Documented
76 @API(status = STABLE, since = "5.0")
77 @Testable
78 public @interface Test {
79 }