Loading...
Spring Framework Reference Documentation 7.0.2의 Key Abstractions의 한국어 번역본입니다.
아래의 경우에 피드백에서 신고해주신다면 반영하겠습니다.
감사합니다 :)
이 framework의 core는 TestContextManager class와 TestContext, TestExecutionListener, SmartContextLoader interface로 구성됩니다. 하나의 TestContextManager는 각 test class마다 생성됩니다 (예를 들어, JUnit Jupiter에서 단일 test class 내의 모든 test method 실행의 경우).
TestContextManager는 차례로 현재 test의 context를 보유하는 TestContext를 관리합니다. TestContextManager는 또한 test가 진행됨에 따라 TestContext의 state를 업데이트하고, 의존성 주입 제공, 트랜잭션 관리 등으로 실제 test 실행을 instrument하는 TestExecutionListener implementation에 위임합니다. SmartContextLoader는 주어진 test class에 대한 ApplicationContext를 로딩하는 역할을 담당합니다. 다양한 implementation에 대한 추가 정보와 예시는 javadoc과 Spring test suite를 참고하십시오.
TestContextTestContext는 test가 실행되는 context를 캡슐화하며 (사용 중인 실제 testing framework에는 agnostic) 자신이 책임지는 test instance에 대해 context 관리 및 캐싱 지원을 제공합니다.
TestContext는 또한 요청 시 ApplicationContext를 로딩하기 위해 SmartContextLoader에 위임합니다.
TestContextManagerTestContextManager는 Spring TestContext Framework에 대한 main entry point이며 단일 TestContext를 관리하고 잘 정의된 test execution 지점에서 각 등록된 TestExecutionListener에 event를 signaling하는 역할을 담당합니다.
TestExecutionListenerTestExecutionListener는 listener가 등록된 TestContextManager가 publish하는 test-execution event에 반응하기 위한 API를 정의합니다. TestExecutionListener 설정을 참고하십시오.
ContextLoader는 Spring TestContext Framework가 관리하는 integration test를 위한 ApplicationContext를 로딩하기 위한 strategy interface입니다. 컴포넌트 class, 활성 빈 정의 프로필, test 속성 소스, context 계층 구조, WebApplicationContext 지원을 제공하려면 이 interface 대신 SmartContextLoader를 구현해야 합니다.
SmartContextLoader는 기존의 최소한의 ContextLoader SPI를 대체하는 ContextLoader interface의 extension입니다. 구체적으로, SmartContextLoader는 resource location, 컴포넌트 class, context initializer를 처리하도록 선택할 수 있습니다. 더욱이, SmartContextLoader는 자신이 로딩하는 context에서 활성 빈 정의 프로필과 test 속성 소스를 설정할 수 있습니다.
Spring은 다음과 같은 implementation을 제공합니다.
DelegatingSmartContextLoader: 두 개의 기본 loader 중 하나로, 내부적으로 AnnotationConfigContextLoader, GenericXmlContextLoader, GenericGroovyXmlContextLoader에 위임하며, 이는 test class에 대해 선언된 설정 또는 기본 location이나 기본 설정 class의 존재 여부에 따라 결정됩니다. Groovy 지원은 Groovy가 classpath에 있는 경우에만 활성화됩니다.WebDelegatingSmartContextLoader: 두 개의 기본 loader 중 하나로, 내부적으로 AnnotationConfigWebContextLoader, GenericXmlWebContextLoader, GenericGroovyXmlWebContextLoader에 위임하며, 이는 test class에 대해 선언된 설정 또는 기본 location이나 기본 설정 class의 존재 여부에 따라 결정됩니다. Web ContextLoader는 @WebAppConfiguration이 test class에 존재하는 경우에만 사용됩니다. Groovy 지원은 Groovy가 classpath에 있는 경우에만 활성화됩니다.AnnotationConfigContextLoader: 컴포넌트 class로부터 standard ApplicationContext를 로딩합니다.AnnotationConfigWebContextLoader: 컴포넌트 class로부터 WebApplicationContext를 로딩합니다.GenericGroovyXmlContextLoader: Groovy script 또는 XML 설정 file인 resource location으로부터 standard ApplicationContext를 로딩합니다.GenericGroovyXmlWebContextLoader: Groovy script 또는 XML 설정 file인 resource location으로부터 WebApplicationContext를 로딩합니다.GenericXmlContextLoader: XML resource location으로부터 standard ApplicationContext를 로딩합니다.GenericXmlWebContextLoader: XML resource location으로부터 WebApplicationContext를 로딩합니다.Spring TestContext Framework
Bootstrapping the TestContext Framework