Reputation: 53
Please support me in understanding and over coming confusion of when to use
@IncludeEngines
and when to use @ExtendWith
in JUnit 5.
Apologies if this question is too basic.
Thank you in advance.
Upvotes: 1
Views: 1852
Reputation: 47935
@ExtendWith
is used to register custom extensions
In terms of JUnit4 constructs: @RunWith
, @Rule
and @ClassRule
have all been superseded by @ExtendWith
. Although JUnit 5 does retain limited support for rules, the JUnit team's strong advice is to move to using @ExtendWith
.
There are examples of some common JUnit4 rules re-implemented as JUnit5 extensions here.
@IncludeEngines
specifies the org.junit.platform.engine.TestEngine
implementation(s) to be included when running a test suite on the JUnit Platform. Although this is in org.junit.platform.suite.api
and is therefore available for developers to use, I can't think of any situation in which you'd need to use it. It could be used to engage a specific engine e.g. the vintage engine rather than the JupiterTestEngine
but that would imply a need to run tests in a JUnit4 environment and this can be achieved using @RunWith(JUnitPlatform.class)
.
Do you think you need to use @IncludeEngines
? If so, I'd suggest explaining why you think you need to use it and you might find that there are other ways to use JUnit5 which doe not require use of @IncludeEngines
.
Upvotes: 2