Class HelidonJunitExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.InvocationInterceptor,org.junit.jupiter.api.extension.ParameterResolver,org.junit.jupiter.api.extension.TestInstanceFactory
This extension starts a CDI container and adds the test class as a bean with support for injection. The test class uses
a CDI scope that follows the test lifecycle as defined by TestInstance.
The container is started lazily during test execution to ensure that it is started after all other extensions.
The container can be customized with the following annotations:
HelidonTest.resetPerTest()force a new CDI container per testDisableDiscoverydisables CDI discoveryAddBeanadd CDI beansAddExtensionadd CDI extensionAddJaxRsadd JAX-RS (Jersey)
The configuration can be customized with the following annotations:
Configurationglobal setting for MicroProfile configurationAddConfigdeclarative key/value pair configurationAddConfigBlockdeclarative fragment configurationAddConfigSourceprogrammatic configuration
See also Socket, a CDI qualifier to inject JAX-RS client or URI.
The container is created per test class by default, unless
HelidonTest.resetPerTest() is true, in
which case the container is created per test method.
The container and the configuration can be customized per method regardless of the value of
HelidonTest.resetPerTest(). The container will be reset accordingly.
It is not recommended to provide a beans.xml along the test classes, as it would combine beans from all tests.
Instead, you should use AddBean to specify the beans per test or method.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) createTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext fc, org.junit.jupiter.api.extension.ExtensionContext ctx) voidinterceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> ic, org.junit.jupiter.api.extension.ExtensionContext ctx) voidinterceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> ic, org.junit.jupiter.api.extension.ExtensionContext ctx) resolveParameter(org.junit.jupiter.api.extension.ParameterContext pc, org.junit.jupiter.api.extension.ExtensionContext ctx) booleansupportsParameter(org.junit.jupiter.api.extension.ParameterContext pc, org.junit.jupiter.api.extension.ExtensionContext ctx) Methods inherited from class io.helidon.testing.junit5.TestJunitExtension
afterAll, afterEach, beforeAll, initStaticContext, initStaticContext, interceptAfterAllMethod, interceptBeforeAllMethod, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestMethod, interceptTestTemplateMethod, invoke, run, runChecked, staticContext, store, storeLookup, supply, supplyCheckedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
interceptAfterAllMethod, interceptBeforeAllMethod, interceptDynamicTest, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestMethod, interceptTestTemplateMethod
-
Constructor Details
-
HelidonJunitExtension
public HelidonJunitExtension()
-
-
Method Details
-
createTestInstance
public Object createTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext fc, org.junit.jupiter.api.extension.ExtensionContext ctx) - Specified by:
createTestInstancein interfaceorg.junit.jupiter.api.extension.TestInstanceFactory
-
interceptBeforeEachMethod
public void interceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> ic, org.junit.jupiter.api.extension.ExtensionContext ctx) throws Throwable - Specified by:
interceptBeforeEachMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Overrides:
interceptBeforeEachMethodin classTestJunitExtension- Throws:
Throwable
-
interceptAfterEachMethod
public void interceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> ic, org.junit.jupiter.api.extension.ExtensionContext ctx) throws Throwable - Specified by:
interceptAfterEachMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Overrides:
interceptAfterEachMethodin classTestJunitExtension- Throws:
Throwable
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Overrides:
beforeEachin classTestJunitExtension
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext pc, org.junit.jupiter.api.extension.ExtensionContext ctx) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
supportsParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver- Overrides:
supportsParameterin classTestJunitExtension- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
resolveParameter
public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext pc, org.junit.jupiter.api.extension.ExtensionContext ctx) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
resolveParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver- Overrides:
resolveParameterin classTestJunitExtension- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-