| JUnit 4 | JUnit 5 | Description |
|---|---|---|
| @BeforeClass | @BeforeAll | Denotes that the annotated method should be executed before all @Tests, @RepeatedTest, @ParameterizedTest, and @TestFactory methods in the current class. |
| @AfterClass | @AfterAll | Denotes that the annotated method should be executed after all @Tests, @RepeatedTest, @ParameterizedTest, and @TestFactory methods in the current class. |
| @Before | @BeforeEach | Denotes that the annotated method should be executed before each @Test, @RepeatedTest, @ParameterizedTest, or @TestFactory method in the current class. |
| @After | @AfterEach | Denotes that the annotated method should be executed after each @Test, @RepeatedTest, @ParameterizedTest, or @TestFactory method in the current class. |
| @Ignore | @Disable | Denotes that the test class or test method is disabled |
| @Categeory | @Tag | Used to declare tags for filtering tests, either at the class or method level |
| @Test | @Test | Denotes that a method is a test method |
| - | @ParameterizedTest | Denotes that a method is a parameterized test. |
| - | @RepeatedTest | Denotes that a method is a test template for a repeated test. |
| - | @TestFactory | Denotes that a method is a test factory for dynamic tests. |
| - | @TestTemplate | Denotes that a method is a template for test cases designed to be invoked multiple times depending on the number of invocation contexts returned by the registered providers. |
| - | @TestClassOrder | Used to configure the test class execution order for @Nested test classes in the annotated test class. |
| @FixMethodOrder | @TestMethodOrder | Used to configure the test method execution order for the annotated test class. |
| - | @TestInstance | Used to configure the test instance lifecycle for the annotated test class. |
| - | @DisplayName | Declares a custom display name for the test class or test method. |
| - | @DisplayNameGeneration | Declares a custom display name generator for the test class. |
| - | @Nested | Denotes that the annotated class is a non-static nested test class. @BeforeAll and @AfterAll methods cannot be used directly in a @Nested test class unless the "per-class" test instance lifecycle is used. |
| - | @Timeout | Used to fail a test, test factory, test template, or lifecycle method if its execution exceeds a given duration. |
| - | @ExtendWith | Used to register extensions declaratively. |
| - | @RegisterExtension | Used to register extensions programmatically via fields. |
| - | @TempDir | Used to supply a temporary directory via field injection or parameter injection in a lifecycle method or test method. |
Last active
April 17, 2022 02:58
-
-
Save weikangchia/95ad1dad2aa03a11936d70429b097eba to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment