Package com.axelor.test
Class GuiceExtension
- java.lang.Object
-
- com.axelor.test.GuiceExtension
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.InvocationInterceptor,org.junit.jupiter.api.extension.TestInstanceFactory
public class GuiceExtension extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.TestInstanceFactory, org.junit.jupiter.api.extension.InvocationInterceptor
JUnit5 test extension that creates injector using the modules provided withGuiceModulesconfiguration.Here is a simple test:
@ExtendWith(GuiceExtension.class) @GuiceModules({MyModule.class}) public class MyTest { @Inject Foo foo; public void testFooInjected() { assertNotNull(foo); } }
-
-
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
Constructors Constructor Description GuiceExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context)voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context)ObjectcreateTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext factoryContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)protected List<Module>getModules(Class<?> klass)voidinterceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> 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
interceptAfterAllMethod, interceptAfterEachMethod, interceptBeforeAllMethod, interceptBeforeEachMethod, interceptDynamicTest, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestTemplateMethod
-
-
-
-
Method Detail
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception- Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
getModules
protected List<Module> getModules(Class<?> klass) throws org.junit.jupiter.api.extension.TestInstantiationException
- Throws:
org.junit.jupiter.api.extension.TestInstantiationException
-
createTestInstance
public Object createTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext factoryContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.TestInstantiationException
- Specified by:
createTestInstancein interfaceorg.junit.jupiter.api.extension.TestInstanceFactory- Throws:
org.junit.jupiter.api.extension.TestInstantiationException
-
interceptTestMethod
public void interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable
- Specified by:
interceptTestMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
-