程序包 org.springframework.test.context
This package contains the Spring TestContext Framework which provides annotation-driven unit and integration testing support that is agnostic of the actual testing framework in use. The same techniques and annotation-based configuration used in, for example, a JUnit environment can also be applied to tests written with TestNG, etc.
In addition to providing generic and extensible testing infrastructure, the Spring TestContext Framework provides out-of-the-box support for Spring-specific integration testing functionality such as context management and caching, dependency injection of test fixtures, and transactional test management with default rollback semantics.
接口概要 接口 说明 ActiveProfilesResolver Strategy interface for programmatically resolving which active bean definition profiles should be used when loading anApplicationContextfor a test class.BootstrapContext BootstrapContextencapsulates the context in which the Spring TestContext Framework is bootstrapped.CacheAwareContextLoaderDelegate ACacheAwareContextLoaderDelegateis responsible for loading and closing application contexts, interacting transparently with aContextCachebehind the scenes.ContextCustomizer Strategy interface for customizingapplication contextsthat are created and managed by the Spring TestContext Framework.ContextCustomizerFactory Factory for creatingContextCustomizers.ContextLoader Strategy interface for loading anapplication contextfor an integration test managed by the Spring TestContext Framework.DynamicPropertyRegistry Registry used with@DynamicPropertySourcemethods so that they can add properties to theEnvironmentthat have dynamically resolved values.SmartContextLoader Strategy interface for loading anapplication contextfor an integration test managed by the Spring TestContext Framework.TestContext TestContextencapsulates the context in which a test is executed, agnostic of the actual testing framework in use.TestContextBootstrapper TestContextBootstrapperdefines the SPI for bootstrapping the Spring TestContext Framework.TestExecutionListener TestExecutionListenerdefines a listener API for reacting to test execution events published by theTestContextManagerwith which the listener is registered.类概要 类 说明 ContextConfigurationAttributes ContextConfigurationAttributesencapsulates the context configuration attributes declared via@ContextConfiguration.MergedContextConfiguration MergedContextConfigurationencapsulates the merged context configuration declared on a test class and all of its superclasses via@ContextConfiguration,@ActiveProfiles, and@TestPropertySource.TestContextManager TestContextManageris the main entry point into the Spring TestContext Framework.枚举概要 枚举 说明 TestConstructor.AutowireMode Defines autowiring modes for parameters in a test constructor.TestExecutionListeners.MergeMode Enumeration of modes that dictate whether or not explicitly declared listeners are merged with the default listeners when@TestExecutionListenersis declared on a class that does not inherit listeners from a superclass.注释类型概要 注释类型 说明 ActiveProfiles ActiveProfilesis a class-level annotation that is used to declare which active bean definition profiles should be used when loading anApplicationContextfor test classes.BootstrapWith @BootstrapWithdefines class-level metadata that is used to determine how to bootstrap the Spring TestContext Framework.ContextConfiguration @ContextConfigurationdefines class-level metadata that is used to determine how to load and configure anApplicationContextfor integration tests.ContextHierarchy @ContextHierarchyis a class-level annotation that is used to define a hierarchy ofApplicationContextsfor integration tests.DynamicPropertySource Method-level annotation for integration tests that need to add properties with dynamic values to theEnvironment's set ofPropertySources.TestConstructor @TestConstructoris a type-level annotation that is used to configure how the parameters of a test class constructor are autowired from components in the test'sApplicationContext.TestExecutionListeners TestExecutionListenersdefines class-level metadata for configuring whichTestExecutionListenersshould be registered with aTestContextManager.TestPropertySource @TestPropertySourceis a class-level annotation that is used to configure theTestPropertySource.locations()of properties files and inlinedTestPropertySource.properties()to be added to theEnvironment's set ofPropertySourcesfor anApplicationContextfor integration tests.TestPropertySources @TestPropertySourcesis a container for one or more@TestPropertySourcedeclarations.