public class SpringExtension extends ObjectSE implements BeforeAllCallback, AfterAllCallback, TestInstancePostProcessor, BeforeEachCallback, AfterEachCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, ParameterResolver
SpringExtension は、Spring TestContext フレームワークを JUnit 5 の Jupiter プログラミングモデルに統合します。 この拡張機能を使用するには、JUnit Jupiter ベースのテストクラスに @ExtendWith(SpringExtension.class)、@SpringJUnitConfig、@SpringJUnitWebConfig のアノテーションを付けるだけです。
EnabledIf, DisabledIf, SpringJUnitConfig, SpringJUnitWebConfig, TestContextManager| コンストラクターと説明 |
|---|
SpringExtension() |
| 修飾子と型 | メソッドと説明 |
|---|---|
void | afterAll(ExtensionContext context)TestContextManager.afterTestClass() へのデリゲート。 |
void | afterEach(ExtensionContext context) |
void | afterTestExecution(ExtensionContext context) |
void | beforeAll(ExtensionContext context)TestContextManager.beforeTestClass() へのデリゲート。 |
void | beforeEach(ExtensionContext context) |
void | beforeTestExecution(ExtensionContext context) |
static ApplicationContext | getApplicationContext(ExtensionContext context) 提供された ExtensionContext に関連付けられた ApplicationContext を取得します。 |
void | postProcessTestInstance(ObjectSE testInstance, ExtensionContext context) |
ObjectSE | resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) |
boolean | supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic void beforeAll(ExtensionContext context) throws ExceptionSE
TestContextManager.beforeTestClass() へのデリゲート。BeforeAllCallback 内の beforeAll ExceptionSEpublic void afterAll(ExtensionContext context) throws ExceptionSE
TestContextManager.afterTestClass() へのデリゲート。AfterAllCallback 内の afterAll ExceptionSEpublic void postProcessTestInstance(ObjectSE testInstance, ExtensionContext context) throws ExceptionSE
TestInstancePostProcessor 内の postProcessTestInstance ExceptionSEpublic void beforeEach(ExtensionContext context) throws ExceptionSE
BeforeEachCallback 内の beforeEach ExceptionSEpublic void beforeTestExecution(ExtensionContext context) throws ExceptionSE
BeforeTestExecutionCallback 内の beforeTestExecution ExceptionSEpublic void afterTestExecution(ExtensionContext context) throws ExceptionSE
AfterTestExecutionCallback 内の afterTestExecution ExceptionSEpublic void afterEach(ExtensionContext context) throws ExceptionSE
TestContextManager.afterTestMethod(java.lang.Object, java.lang.reflect.Method, java.lang.Throwable) へのデリゲート。AfterEachCallback 内の afterEach ExceptionSEpublic boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
ParameterContext の ParameterSE の値をテストの ApplicationContext からオートワイヤーする必要があるかどうかを決定します。 次のいずれかの条件が true の場合、パラメーターは自動書き込み可能と見なされます。
ConstructorSE であり、TestConstructorUtils.isAutowirableConstructor(Constructor, Class) は true を返します。ApplicationContext またはそのサブ型です。ParameterResolutionDelegate.isAutowirable(java.lang.reflect.Parameter, int) は true を返します。 警告 : テストクラス Constructor に @Autowired のアノテーションが付けられているか、自動的に自動書き込み可能(TestConstructor を参照)の場合、Spring がコンストラクター内のすべてのパラメーターを解決する責任を負います。その結果、他の登録済み ParameterResolver はパラメーターを解決できなくなります。
ParameterResolver 内の supportsParameter resolveParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext), TestConstructorUtils.isAutowirableConstructor(Constructor, Class), ParameterResolutionDelegate.isAutowirable(java.lang.reflect.Parameter, int)@Nullable public ObjectSE resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
ParameterResolver 内の resolveParameter supportsParameter(org.junit.jupiter.api.extension.ParameterContext, org.junit.jupiter.api.extension.ExtensionContext), ParameterResolutionDelegate.resolveDependency(java.lang.reflect.Parameter, int, java.lang.Class<?>, org.springframework.beans.factory.config.AutowireCapableBeanFactory)public static ApplicationContext getApplicationContext(ExtensionContext context)
ExtensionContext に関連付けられた ApplicationContext を取得します。context - 現在の ExtensionContext (非 null)IllegalStateExceptionSE - アプリケーションコンテキストの取得中にエラーが発生した場合 TestContext.getApplicationContext()