|
11 | 11 | import static org.hibernate.testing.bytecode.enhancement.extension.engine.BytecodeEnhancedClassUtils.enhanceTestClass; |
12 | 12 | import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation; |
13 | 13 |
|
| 14 | +import java.lang.reflect.Constructor; |
| 15 | +import java.lang.reflect.InvocationTargetException; |
14 | 16 | import java.lang.reflect.Method; |
15 | 17 | import java.util.Arrays; |
16 | 18 | import java.util.HashSet; |
|
46 | 48 | import org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor; |
47 | 49 | import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext; |
48 | 50 | import org.junit.platform.engine.EngineDiscoveryRequest; |
| 51 | +import org.junit.platform.engine.EngineExecutionListener; |
49 | 52 | import org.junit.platform.engine.ExecutionRequest; |
50 | 53 | import org.junit.platform.engine.TestDescriptor; |
51 | 54 | import org.junit.platform.engine.UniqueId; |
@@ -216,6 +219,15 @@ private Method findMethodReplacement(ClassTestDescriptor updated, Method testMet |
216 | 219 |
|
217 | 220 | @Override |
218 | 221 | protected JupiterEngineExecutionContext createExecutionContext(ExecutionRequest request) { |
| 222 | + try { |
| 223 | + // Try constructing the JupiterEngineExecutionContext the way it was done in 5.12 and before |
| 224 | + final Constructor<JupiterEngineExecutionContext> constructorV5_12 = JupiterEngineExecutionContext.class |
| 225 | + .getConstructor( EngineExecutionListener.class, JupiterConfiguration.class ); |
| 226 | + return constructorV5_12.newInstance( request.getEngineExecutionListener(), this.getJupiterConfiguration( request ) ); |
| 227 | + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e ) { |
| 228 | + // Ignore errors as they are probably due to version mismatches and try the 5.13 way |
| 229 | + } |
| 230 | + |
219 | 231 | return new JupiterEngineExecutionContext( |
220 | 232 | request.getEngineExecutionListener(), |
221 | 233 | this.getJupiterConfiguration( request ), |
|
0 commit comments