3.2. Migration Tips
The following are topics that you should be aware of when migrating existing JUnit 4 tests to JUnit Jupiter.
Annotations reside in the
org.junit.jupiter.api
package.Assertions reside in
org.junit.jupiter.api.Assertions
.Assumptions reside in
org.junit.jupiter.api.Assumptions
.- Note that JUnit Jupiter 5.4 and later versions support methods from JUnit 4’s
org.junit.Assume
class for assumptions. Specifically, JUnit Jupiter supports JUnit 4’sAssumptionViolatedException
to signal that a test should be aborted instead of marked as a failure.
- Note that JUnit Jupiter 5.4 and later versions support methods from JUnit 4’s
@Before
and@After
no longer exist; use@BeforeEach
and@AfterEach
instead.@BeforeClass
and@AfterClass
no longer exist; use@BeforeAll
and@AfterAll
instead.@Ignore
no longer exists: use@Disabled
or one of the other built-in execution conditions instead- See also JUnit 4 @Ignore Support.
@Category
no longer exists; use@Tag
instead.@RunWith
no longer exists; superseded by@ExtendWith
.@Rule
and@ClassRule
no longer exist; superseded by@ExtendWith
and@RegisterExtension
- See also Limited JUnit 4 Rule Support.