Difference between JUnit 4 and JUnit 5
Explore the key distinctions between JUnit 4 and JUnit 5, focusing on annotation changes, test lifecycle hooks, and Java Development Kit compatibility. This lesson prepares you to migrate your unit tests to JUnit 5 with clarity on updated features and support.
This lesson will help us understand the differences between JUnit 4 and JUnit 5.
JUnit 4 and JUnit 5 comparison
The table below shows a side-by-side comparison of annotations used in JUnit 4 and JUnit 5.
JUnit 5 | JUnit 4 |
@Test | @Test |
@BeforeEach | @Before |
@BeforeAll | @BeforeClass |
@AfterEach | @After |
@AfterAll | @AfterClass |
@Disabled | @Ignore |
@Tag | @Category |
@ExtendWith | @RunWith |
...