I am writing an extension for a test using @ParameterizedTest. My test looks like:
@ParameterizedTest
@ValueSource(strings={"string1", "string2"})
public void test1(String name){
System.out.println(name);
}
In the extensions, how do I get the TestDesciptor to find out which invocation in currently active?
public class MyExtension implements BeforeEachCallBack{
@Override
public void beforeEach(ExtensionContext extensionContext)
// What to do here? extensionContext.?
}
}
As you can see by its package name
org.junit.platform.engine.TestDescriptoris not part of JUnit Jupiter API which hasorg.junit.jupiter.apias its base package. Moreover,org.junit.platform.engineis not even imported by the API.So the sad answer is you cannot get at the test descriptor, at least not without some dirty and unstable reflection. I am, however, quite sure that the underlying reason you have for wanting access can be mitigated in a different way. So what is it you’d like to achieve?