Skip to content

Commit e8a5185

Browse files
committed
Ensure compatibility with JUnit < 5.13
1 parent f359b4a commit e8a5185

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

hibernate-testing/src/main/java/org/hibernate/testing/bytecode/enhancement/extension/engine/BytecodeEnhancedTestEngine.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import static org.hibernate.testing.bytecode.enhancement.extension.engine.BytecodeEnhancedClassUtils.enhanceTestClass;
1010
import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;
1111

12+
import java.lang.reflect.Constructor;
13+
import java.lang.reflect.InvocationTargetException;
1214
import java.lang.reflect.Method;
1315
import java.util.Arrays;
1416
import java.util.HashSet;
@@ -43,6 +45,7 @@
4345
import org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor;
4446
import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext;
4547
import org.junit.platform.engine.EngineDiscoveryRequest;
48+
import org.junit.platform.engine.EngineExecutionListener;
4649
import org.junit.platform.engine.ExecutionRequest;
4750
import org.junit.platform.engine.TestDescriptor;
4851
import org.junit.platform.engine.UniqueId;
@@ -213,6 +216,15 @@ private Method findMethodReplacement(ClassTestDescriptor updated, Method testMet
213216

214217
@Override
215218
protected JupiterEngineExecutionContext createExecutionContext(ExecutionRequest request) {
219+
try {
220+
// Try constructing the JupiterEngineExecutionContext the way it was done in 5.12 and before
221+
final Constructor<JupiterEngineExecutionContext> constructorV5_12 = JupiterEngineExecutionContext.class
222+
.getConstructor( EngineExecutionListener.class, JupiterConfiguration.class );
223+
return constructorV5_12.newInstance( request.getEngineExecutionListener(), this.getJupiterConfiguration( request ) );
224+
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e ) {
225+
// Ignore errors as they are probably due to version mismatches and try the 5.13 way
226+
}
227+
216228
return new JupiterEngineExecutionContext(
217229
request.getEngineExecutionListener(),
218230
this.getJupiterConfiguration( request )

0 commit comments

Comments
 (0)