Debian Codegraph @

junit-jupiter-api/src/main/java/org/junit/jupiter/api/TestClassOrder.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.Inherited;
18 import java.lang.annotation.Retention;
19 import java.lang.annotation.RetentionPolicy;
20 import java.lang.annotation.Target;
21
22 import org.apiguardian.api.API;
23
24 /**
25 * {@code @TestClassOrder} is a type-level annotation that is used to configure
26 * a {@link #value ClassOrderer} for the {@link Nested @Nested} test classes of
27 * the annotated test class.
28 *
29 * <p>If {@code @TestClassOrder} is not explicitly declared on a test class,
30 * inherited from a parent class, declared on a test interface implemented by
31 * a test class, or inherited from an {@linkplain Class#getEnclosingClass() enclosing
32 * class}, {@code @Nested} test classes will be executed in arbitrary order.
33 *
34 * <p>As an alternative to {@code @TestClassOrder}, a global {@link ClassOrderer}
35 * can be configured for the entire test suite via the
36 * {@value ClassOrderer#DEFAULT_ORDER_PROPERTY_NAME} configuration parameter. See
37 * the User Guide for details. Note, however, that a {@code @TestClassOrder}
38 * declaration always overrides a global {@code ClassOrderer}.
39 *
40 * <h2>Example Usage</h2>
41 *
42 * <p>The following demonstrates how to guarantee that {@code @Nested} test classes
43 * are executed in the order specified via the {@link Order @Order} annotation.
44 *
45 * <pre class="code">
46 * {@literal @}TestClassOrder(ClassOrderer.OrderAnnotation.class)
47 * class OrderedNestedTests {
48 *
49 * {@literal @}Nested
50 * {@literal @}Order(1)
51 * class PrimaryTests {
52 * // {@literal @}Test methods ...
53 * }
54 *
55 * {@literal @}Nested
56 * {@literal @}Order(2)
57 * class SecondaryTests {
58 * // {@literal @}Test methods ...
59 * }
60 * }
61 * </pre>
62 *
63 * @since 5.8
64 * @see ClassOrderer
65 * @see TestMethodOrder
66 */
67 @Target(ElementType.TYPE)
68 @Retention(RetentionPolicy.RUNTIME)
69 @Documented
70 @Inherited
71 @API(status = STABLE, since = "5.10")
72 public @interface TestClassOrder {
73
74 /**
75 * The {@link ClassOrderer} to use.
76 *
77 * @see ClassOrderer
78 * @see ClassOrderer.ClassName
79 * @see ClassOrderer.DisplayName
80 * @see ClassOrderer.OrderAnnotation
81 * @see ClassOrderer.Random
82 */
83 Class<? extends ClassOrderer> value();
84
85 }