Skip to content

Use constructor as fallback for ExecutionRequest creation in JUnit5 instrumentation #8871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.platform.commons.JUnitException;
import org.junit.platform.commons.util.ClassLoaderUtils;
import org.junit.platform.commons.util.ReflectionUtils;
import org.junit.platform.engine.ConfigurationParameters;
import org.junit.platform.engine.EngineExecutionListener;
import org.junit.platform.engine.ExecutionRequest;
import org.junit.platform.engine.TestDescriptor;
Expand Down Expand Up @@ -116,12 +117,6 @@ private JUnitPlatformUtils() {}
METHOD_HANDLES.method(ExecutionRequest.class, "getOutputDirectoryProvider");
private static final MethodHandle GET_STORE =
METHOD_HANDLES.method(ExecutionRequest.class, "getStore");
private static final String[] CREATE_FALLBACK_PARAMETER_TYPES =
new String[] {
"org.junit.platform.engine.TestDescriptor",
"org.junit.platform.engine.EngineExecutionListener",
"org.junit.platform.engine.ConfigurationParameters"
};
private static final String[] CREATE_PARAMETER_TYPES =
new String[] {
"org.junit.platform.engine.TestDescriptor",
Expand All @@ -143,14 +138,11 @@ private static MethodHandle createExecutionRequestHandle() {
Arrays.stream(m.getParameterTypes()).map(Class::getName).toArray(),
CREATE_PARAMETER_TYPES));
} else {
return METHOD_HANDLES.method(
return METHOD_HANDLES.constructor(
ExecutionRequest.class,
m ->
"create".equals(m.getName())
&& m.getParameterCount() == 3
&& Arrays.equals(
Arrays.stream(m.getParameterTypes()).map(Class::getName).toArray(),
CREATE_FALLBACK_PARAMETER_TYPES));
TestDescriptor.class,
EngineExecutionListener.class,
ConfigurationParameters.class);
}
}

Expand Down