C
- The extension contextpublic abstract class AbstractMicronautExtension<C> extends java.lang.Object implements TestExecutionListener
Modifier and Type | Field and Description |
---|---|
protected io.micronaut.context.ApplicationContext |
applicationContext |
static java.lang.String |
DISABLED_MESSAGE |
protected io.micronaut.runtime.EmbeddedApplication |
embeddedApplication |
static java.lang.String |
MISCONFIGURED_MESSAGE |
protected java.util.Map<java.lang.String,java.lang.Object> |
oldValues |
protected io.micronaut.runtime.context.scope.refresh.RefreshScope |
refreshScope |
protected io.micronaut.inject.BeanDefinition<?> |
specDefinition |
static java.lang.String |
TEST_PROPERTY_SOURCE
The name of the property source that contains test properties.
|
static java.lang.String |
TEST_ROLLBACK |
static java.lang.String |
TEST_TRANSACTION_MODE |
static java.lang.String |
TEST_TRANSACTIONAL |
protected java.util.Map<java.lang.String,java.lang.Object> |
testProperties |
Constructor and Description |
---|
AbstractMicronautExtension() |
Modifier and Type | Method and Description |
---|---|
protected void |
afterClass(C context)
Executed after the class is complete.
|
void |
afterCleanupTest(TestContext testContext)
Executed after the setup method of a test method.
|
void |
afterEach(C context)
Executed after each test completes.
|
void |
afterSetupTest(TestContext testContext)
Executed after the setup method of a test method.
|
void |
afterTestClass(TestContext testContext)
Executed after all of the tests of a class have bean executed.
|
void |
afterTestExecution(TestContext testContext)
Executed after a single test iteration has been executed .
|
void |
afterTestMethod(TestContext testContext)
Executed after a test method has been executed (a test method may contain multiple
iterations).
|
protected abstract void |
alignMocks(C context,
java.lang.Object instance) |
protected void |
beforeClass(C context,
java.lang.Class<?> testClass,
MicronautTestValue testAnnotationValue)
Executed before tests within a class are run.
|
void |
beforeCleanupTest(TestContext testContext)
Executed before the setup method of a test method.
|
protected void |
beforeEach(C context,
java.lang.Object testInstance,
java.lang.reflect.AnnotatedElement method,
java.util.List<io.micronaut.context.annotation.Property> propertyAnnotations)
To be called by the different implementations before each test method.
|
void |
beforeSetupTest(TestContext testContext)
Executed before the setup method of a test method.
|
void |
beforeTestClass(TestContext testContext)
Executed before all of the tests of a class are executed.
|
void |
beforeTestExecution(TestContext testContext)
Executed before a single test iteration is executed.
|
void |
beforeTestMethod(TestContext testContext)
Executed before a test method is executed (a test method may contain multiple iterations).
|
protected boolean |
isTestSuiteBeanPresent(java.lang.Class<?> requiredTestClass) |
protected void |
postProcessBuilder(io.micronaut.context.ApplicationContextBuilder builder)
Allows subclasses to customize the builder right before context initialization.
|
protected abstract void |
resolveTestProperties(C context,
MicronautTestValue testAnnotationValue,
java.util.Map<java.lang.String,java.lang.Object> testProperties)
Resolves any test properties.
|
protected void |
startApplicationContext()
Starts the application context.
|
public static final java.lang.String TEST_ROLLBACK
public static final java.lang.String TEST_TRANSACTIONAL
public static final java.lang.String TEST_TRANSACTION_MODE
public static final java.lang.String DISABLED_MESSAGE
public static final java.lang.String MISCONFIGURED_MESSAGE
public static final java.lang.String TEST_PROPERTY_SOURCE
protected io.micronaut.context.ApplicationContext applicationContext
protected io.micronaut.runtime.EmbeddedApplication embeddedApplication
protected io.micronaut.runtime.context.scope.refresh.RefreshScope refreshScope
protected io.micronaut.inject.BeanDefinition<?> specDefinition
protected java.util.Map<java.lang.String,java.lang.Object> testProperties
protected java.util.Map<java.lang.String,java.lang.Object> oldValues
public void beforeTestExecution(TestContext testContext) throws java.lang.Exception
beforeTestExecution
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void beforeCleanupTest(TestContext testContext) throws java.lang.Exception
TestExecutionListener
beforeCleanupTest
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void afterCleanupTest(TestContext testContext) throws java.lang.Exception
TestExecutionListener
afterCleanupTest
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void afterTestExecution(TestContext testContext) throws java.lang.Exception
afterTestExecution
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void beforeTestClass(TestContext testContext) throws java.lang.Exception
beforeTestClass
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void afterTestClass(TestContext testContext) throws java.lang.Exception
afterTestClass
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void beforeSetupTest(TestContext testContext) throws java.lang.Exception
TestExecutionListener
beforeSetupTest
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void afterSetupTest(TestContext testContext) throws java.lang.Exception
TestExecutionListener
afterSetupTest
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void beforeTestMethod(TestContext testContext) throws java.lang.Exception
beforeTestMethod
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagatepublic void afterTestMethod(TestContext testContext) throws java.lang.Exception
afterTestMethod
in interface TestExecutionListener
testContext
- the test contextjava.lang.Exception
- allows any exception to propagateprotected void beforeClass(C context, java.lang.Class<?> testClass, @Nullable MicronautTestValue testAnnotationValue)
context
- The test contexttestClass
- The test classtestAnnotationValue
- The test annotation valuesprotected void postProcessBuilder(io.micronaut.context.ApplicationContextBuilder builder)
builder
- the application context builderprotected abstract void resolveTestProperties(C context, MicronautTestValue testAnnotationValue, java.util.Map<java.lang.String,java.lang.Object> testProperties)
context
- The test contexttestAnnotationValue
- The test annotationtestProperties
- The test propertiesprotected void beforeEach(C context, @Nullable java.lang.Object testInstance, @Nullable java.lang.reflect.AnnotatedElement method, java.util.List<io.micronaut.context.annotation.Property> propertyAnnotations)
context
- The test contexttestInstance
- The test instancemethod
- The test methodpropertyAnnotations
- The @Property
annotations found in the test method, if anyprotected void afterClass(C context)
context
- the contextpublic void afterEach(C context) throws java.lang.Exception
context
- The contextjava.lang.Exception
- allows any exception to propagateprotected void startApplicationContext()
protected boolean isTestSuiteBeanPresent(java.lang.Class<?> requiredTestClass)
requiredTestClass
- The test classprotected abstract void alignMocks(C context, java.lang.Object instance)
context
- The contextinstance
- The mock instance to inject