Package org.junit.jupiter.api

JUnit Jupiter API for writing tests.
  • Interface Summary
    Interface Description
    ClassDescriptor
    ClassDescriptor encapsulates functionality for a given Class.
    ClassOrderer
    ClassOrderer defines the API for ordering the top-level test classes, without considering nested test classes.
    ClassOrdererContext
    ClassOrdererContext encapsulates the context in which a ClassOrderer will be invoked.
    DisplayNameGenerator
    DisplayNameGenerator defines the SPI for generating display names programmatically.
    MethodDescriptor
    MethodDescriptor encapsulates functionality for a given Method.
    MethodOrderer
    MethodOrderer defines the API for ordering the test methods in a given test class.
    MethodOrdererContext
    MethodOrdererContext encapsulates the context in which a MethodOrderer will be invoked.
    Named<T>
    Named is used to wrap an object and give it a name.
    RepetitionInfo
    RepetitionInfo is used to inject information about the current repetition of a repeated test into @RepeatedTest, @BeforeEach, and @AfterEach methods.
    TestInfo
    TestInfo is used to inject information about the current test or container into to @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, @BeforeEach, @AfterEach, @BeforeAll, and @AfterAll methods.
    TestReporter
    Parameters of type TestReporter can be injected into @BeforeEach and @AfterEach lifecycle methods as well as methods annotated with @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, etc.
  • Class Summary
    Class Description
    Assertions
    Assertions is a collection of utility methods that support asserting conditions in tests.
    Assumptions
    Assumptions is a collection of utility methods that support conditional test execution based on assumptions.
    ClassOrderer.ClassName
    ClassOrderer that sorts classes alphanumerically based on their fully qualified names using String.compareTo(String).
    ClassOrderer.DisplayName
    ClassOrderer that sorts classes alphanumerically based on their display names using String.compareTo(String)
    ClassOrderer.OrderAnnotation
    ClassOrderer that sorts classes based on the @Order annotation.
    ClassOrderer.Random
    ClassOrderer that orders classes pseudo-randomly.
    DisplayNameGenerator.IndicativeSentences
    DisplayNameGenerator that generates complete sentences.
    DisplayNameGenerator.ReplaceUnderscores
    DisplayNameGenerator that replaces underscores with spaces.
    DisplayNameGenerator.Simple
    Simple DisplayNameGenerator that removes trailing parentheses for methods with no parameters.
    DisplayNameGenerator.Standard
    Standard DisplayNameGenerator.
    DynamicContainer
    A DynamicContainer is a container generated at runtime.
    DynamicNode
    DynamicNode serves as the abstract base class for a container or a test case generated at runtime.
    DynamicTest
    A DynamicTest is a test case generated at runtime.
    MethodOrderer.Alphanumeric Deprecated.
    as of JUnit Jupiter 5.7 in favor of MethodOrderer.MethodName; to be removed in 6.0
    MethodOrderer.DisplayName
    MethodOrderer that sorts methods alphanumerically based on their display names using String.compareTo(String)
    MethodOrderer.MethodName
    MethodOrderer that sorts methods alphanumerically based on their names using String.compareTo(String).
    MethodOrderer.OrderAnnotation
    MethodOrderer that sorts methods based on the @Order annotation.
    MethodOrderer.Random
    MethodOrderer that orders methods pseudo-randomly.
  • Enum Summary
    Enum Description
    TestInstance.Lifecycle
    Enumeration of test instance lifecycle modes.
  • Annotation Types Summary
    Annotation Type Description
    AfterAll
    @AfterAll is used to signal that the annotated method should be executed after all tests in the current test class.
    AfterEach
    @AfterEach is used to signal that the annotated method should be executed after each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, and @TestTemplate method in the current test class.
    BeforeAll
    @BeforeAll is used to signal that the annotated method should be executed before all tests in the current test class.
    BeforeEach
    @BeforeEach is used to signal that the annotated method should be executed before each @Test, @RepeatedTest, @ParameterizedTest, @TestFactory, and @TestTemplate method in the current test class.
    Disabled
    @Disabled is used to signal that the annotated test class or test method is currently disabled and should not be executed.
    DisplayName
    @DisplayName is used to declare a custom display name for the annotated test class or test method.
    DisplayNameGeneration
    @DisplayNameGeneration is used to declare a custom display name generator for the annotated test class.
    IndicativeSentencesGeneration
    @IndicativeSentencesGeneration is used to declare a custom parameters by IndicativeSentences, if this notation has some not declared parameters, it will use the default values instead.
    Nested
    @Nested is used to signal that the annotated class is a nested, non-static test class (i.e., an inner class) that can share setup and state with an instance of its enclosing class.
    Order
    @Order is an annotation that is used to configure the order in which the annotated element (i.e., field, method, or class) should be evaluated or executed relative to other elements of the same category.
    RepeatedTest
    @RepeatedTest is used to signal that the annotated method is a test template method that should be repeated a specified number of times with a configurable display name.
    Tag
    @Tag is a repeatable annotation that is used to declare a tag for the annotated test class or test method.
    Tags
    @Tags is a container for one or more @Tag declarations.
    Test
    @Test is used to signal that the annotated method is a test method.
    TestFactory
    @TestFactory is used to signal that the annotated method is a test factory method.
    TestInstance
    @TestInstance is a type-level annotation that is used to configure the lifecycle of test instances for the annotated test class or test interface.
    TestMethodOrder
    @TestMethodOrder is a type-level annotation that is used to configure a MethodOrderer for the test methods of the annotated test class or test interface.
    TestTemplate
    @TestTemplate is used to signal that the annotated method is a test template method.
    Timeout
    @Timeout is used to define a timeout for a method or all testable methods within one class and its @Nested classes.