The Spring Framework provides the following set of Spring-specific annotations that you can use in your unit and integration tests in conjunction with the TestContext framework. See the corresponding javadoc for further information, including default attribute values, attribute aliases, and other details.
스프링 프레임워크는 다음와 같은 스프링 특화 어노테이션을 제공한다. 이 어노테이션들은 유닛테스트 혹은 통합테스트를 할때 테스트 프레임워크(TestContext framework)와의 연결을 위해서 사용된다. 디폴트값, 속성, 등 더많은 정보를 위해서는 대응되는 javadoc을 보도록 하라.
Spring’s testing annotations include the following:
@BootstrapWithis a class-level annotation that you can use to configure how the Spring TestContext Framework is bootstrapped. Specifically, you can use@BootstrapWithto specify a customTestContextBootstrapper. See the section onbootstrapping the TestContext frameworkfor further details.
@BootstrapWith는 클래스 레벨 어노테이션이다. 어떻게 스프링 테스트 프레이워크가 부트스트랩 되는지를 정의한다. 특히, @BootstrapWith를 사용하면 커스텀 테스트 컨텍스트 부트스트랩퍼를 지정할 수 있다. 더 많은 정보를 위해서 bootstrapping the TestContext framework 를 참조하도록 하라.
@ContextConfiguration
@ContextConfigurationdefines class-level metadata that is used to determine how to load and configure anApplicationContextfor integration tests. Specifically,@ContextConfigurationdeclares the application context resourcelocationsor the componentclassesused to load the context.
@ContextConfiguration은 클래스 레벨 메타데이터를 정의한다. 메타데이터는 통합 테스트를 위한 어플리케이션 컨텍스트를 어떻게 구성 하고, 로드 하는지를 정의한다. 특히, @ContextConfiguration은 어플리케이션 컨텍스트 리소스의 위치(location) 혹은 컨텍스트를 로드할때 사용되는 클래스의 컴포넌트를 선언한다.
@WebAppConfiguration
@WebAppConfigurationis a class-level annotation that you can use to declare that theApplicationContextloaded for an integration test should be aWebApplicationContext. The mere presence of@WebAppConfigurationon a test class ensures that aWebApplicationContextis loaded for the test, using the default value of"file:src/main/webapp"for the path to the root of the web application (that is, the resource base path). The resource base path is used behind the scenes to create aMockServletContext, which serves as theServletContextfor the test’sWebApplicationContext.
@WebAppConfiguration은 클래스 레벨 어노테이션이다. @WebAppConfiguration은 통합 테스트를 위한 어플리케이션 컨텍스트가 WebApplicationContext여야 하는 경우 사용된다. @WebAppConfiguration가 사용되는 유일한 이유는 테스트를 할때WebApplicationContext가 로드되었다는것을 보장해주고, 웹 어플리케이션의 루트 패스인 "file:src/main/webapp"를 디폴트 값으로 사용하는것을 보장하는 것이다. 리소스의 베이스 패스는 Mock서블렛 컨텍스트를 생성하기위해서 사용되며 Mock서블렛 컨텍스트는 WebApplicationContext의 테스트에 사용되는 서블렛 컨텍스트 역할을 수행한다.
@ContextHierarchy
@ContextHierarchyis a class-level annotation that is used to define a hierarchy ofApplicationContextinstances for integration tests.@ContextHierarchyshould be declared with a list of one or more@ContextConfigurationinstances, each of which defines a level in the context hierarchy.
@ContextHierachy는 클래스레벨 어노테이션이다. @ContextHierarchy는 통합 테스트시 어플리케이션 컨텍스트의 인스턴스의 계층을 정의하기위해 사용된다. @ContextHierachy는 하나 이상의 @ContextConfiguration인스턴스와 함께 정의 되어야한다. 이때 사용되는 각 @ContextConfiguration가 컨텍스트 계층 레벨을 정의한다.
@ActiveProfiles
@ActiveProfilesis a class-level annotation that is used to declare which bean definition profiles should be active when loading anApplicationContextfor an integration test.
@ActiveProfiles는 클래스 레벨 어노테이션이다. @ActiveProfiles는 통합 테스트시 어플리케이션 컨텍스를 로딩할때 어떤 빈 정의 프로파일이 활성화 되어야하는지를 정의한다.
@TestPropertySource
@TestPropertySourceis a class-level annotation that you can use to configure the locations of properties files and inlined properties to be added to the set ofPropertySourcesin theEnvironmentfor anApplicationContextloaded for an integration test.