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