类 SpringBootContextLoader

  • 所有已实现的接口:
    org.springframework.test.context.ContextLoader, org.springframework.test.context.SmartContextLoader

    public class SpringBootContextLoader
    extends org.springframework.test.context.support.AbstractContextLoader
    A ContextLoader that can be used to test Spring Boot applications (those that normally startup using SpringApplication). Although this loader can be used directly, most test will instead want to use it with SpringBootTest.

    The loader supports both standard MergedContextConfiguration as well as WebMergedContextConfiguration. If WebMergedContextConfiguration is used the context will either use a mock servlet environment, or start the full embedded servlet container.

    If @ActiveProfiles are provided in the test class they will be used to create the application context.

    另请参阅:
    SpringBootTest
    • 方法详细资料

      • loadContext

        public org.springframework.context.ApplicationContext loadContext​(org.springframework.test.context.MergedContextConfiguration config)
                                                                   throws Exception
        抛出:
        Exception
      • getSpringApplication

        protected org.springframework.boot.SpringApplication getSpringApplication()
        Builds new SpringApplication instance. You can override this method to add custom behavior
        返回:
        SpringApplication instance
      • getInlinedProperties

        protected String[] getInlinedProperties​(org.springframework.test.context.MergedContextConfiguration config)
      • processContextConfiguration

        public void processContextConfiguration​(org.springframework.test.context.ContextConfigurationAttributes configAttributes)
        指定者:
        processContextConfiguration 在接口中 org.springframework.test.context.SmartContextLoader
        覆盖:
        processContextConfiguration 在类中 org.springframework.test.context.support.AbstractContextLoader
      • detectDefaultConfigurationClasses

        protected Class<?>[] detectDefaultConfigurationClasses​(Class<?> declaringClass)
        Detect the default configuration classes for the supplied test class. By default simply delegates to AnnotationConfigContextLoaderUtils.detectDefaultConfigurationClasses(java.lang.Class<?>) .
        参数:
        declaringClass - the test class that declared @ContextConfiguration
        返回:
        an array of default configuration classes, potentially empty but never null
        另请参阅:
        AnnotationConfigContextLoaderUtils
      • getResourceSuffixes

        protected String[] getResourceSuffixes()
        覆盖:
        getResourceSuffixes 在类中 org.springframework.test.context.support.AbstractContextLoader
      • getResourceSuffix

        protected String getResourceSuffix()
        指定者:
        getResourceSuffix 在类中 org.springframework.test.context.support.AbstractContextLoader