-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Migrating from TestNG to JUnit Jupiter
Sam Brannen edited this page Jun 20, 2024
·
6 revisions
- Test classes should be annotated with
@TestInstance(Lifecycle.PER_CLASS)
to align with TestNG semantics. -
@BeforeClass
/@AfterClass
methods should be annotated with@BeforeAll
/@AfterAll
. - Tests using data providers should be converted to parameterized tests (
@ParameterizedTest
). - The order of the
expected
andactual
arguments to assertion methods such asassertEquals(...)
needs to be swapped so that theexpected
result precedes theactual
result. - Usage of
expectThrows(...)
should be changed toassertThrows(...)
. - Tests that threw
SkipException
should make use of the theAssumptions
API.