Package org.spongepowered.mij
Class ModLauncherExtension
java.lang.Object
org.spongepowered.mij.ModLauncherExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.InvocationInterceptor
,MethodInvocationInterceptor
A JUnit extension booting ModLauncher and executing tests inside the transforming class loader.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T extends Object>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Class<?>
getTransformedClass
(Class<?> originalClass) protected Constructor<?>
getTransformedConstructor
(Constructor<?> originalConstructor) protected Object
getTransformedInstance
(Object originalInstance) protected Method
getTransformedMethod
(Method originalMethod) protected abstract ClassLoader
Gets the transforming class loader in which tests are executed.<T> T
interceptMethod
(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Intercepts the invocation of any method.<T> T
interceptTestClassConstructor
(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Constructor<T>> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
interceptDynamicTest, interceptDynamicTest
Methods inherited from interface org.spongepowered.mij.MethodInvocationInterceptor
interceptAfterAllMethod, interceptAfterEachMethod, interceptBeforeAllMethod, interceptBeforeEachMethod, interceptTestFactoryMethod, interceptTestMethod, interceptTestTemplateMethod
-
Constructor Details
-
ModLauncherExtension
public ModLauncherExtension()
-
-
Method Details
-
interceptTestClassConstructor
public <T> T interceptTestClassConstructor(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Constructor<T>> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestClassConstructor
in interfaceorg.junit.jupiter.api.extension.InvocationInterceptor
- Throws:
Throwable
-
interceptMethod
public <T> T interceptMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable Description copied from interface:MethodInvocationInterceptor
Intercepts the invocation of any method.- Specified by:
interceptMethod
in interfaceMethodInvocationInterceptor
- Parameters:
invocation
- The invocation that is being intercepted; nevernull
invocationContext
- The context of the invocation that is being intercepted; nevernull
extensionContext
- The current extension context; nevernull
- Throws:
Throwable
- In case of failures
-
getTransformedInstance
-
getTransformedConstructor
-
getTransformedMethod
-
getTransformedClass
-
getTransformingClassLoader
Gets the transforming class loader in which tests are executed. A typical implementation of this method will invokeSharedModLauncher.getTransformingClassLoader(String[])
with the launch target set in the arguments.- Returns:
- The transforming class loader
-