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