Unlike previous versions of JUnit, JUnit 5 is composed of several different modules from three different sub-projects.
JUnit 5 requires Java 8 (or higher) at runtime. However, you can still test code that has been compiled with previous versions of the JDK
JUnit 5 replaces JUnit 4 annotations
@Before
>> @BeforeEach
@BeforeClass
>> @BeforeAll
@After
>> @AfterEach
@AfterClass
>> @AfterAll
@Ignore
>> @Disabled
JUnit 5 also introductes new annotations
@DisplayName
@Nested
@ParameterizedTest
For detailed information on these annotations, please see JUnit 5 Annotations
JUnit 5 introduces new assertions
assertThrows
assertTimeout
assertAll
For detailed information on these annotations, please see JUnit 5 Assertions
For detailed information on these annotations, please see JUnit 5 Extension Model
@RunWith(JUnitPlatform.class)
For detailed information on these annotations, please see JUnit 5 Using JUnit 4 to run JUnit Platform
@Autowired
, @Qualifier
, @Value
@ExtendWith(SpringExtension.class)
@SpringJUnitConfig
= @ExtendWith(SpringExtension.class) +
@ContextConfiguration
For detailed information on these annotations, please see Spring TestContext Framework Extension for JUnit 5