Is it possible to use extension depending on some condition in JUnit5?
I have extension that collect and send test run results to external service (TestRail). But I want to have it enabled for remote runs and disabled for local runs. E.g. something like this:
TestRailListener implements BeforeAllCallback, TestWatcher
@BeforeAll
public void beforeAll() {
if(!Objects.equals(System.getProperty("runType"), "local")) {
Extension e = new TestRailListener().enable();
}
Is there any way to achieve it?
JUnit Jupiter provides Programmatic Extension Registration.
So you can configure you extensions with additional parameters at runtime.