2016-07-04 9 views
8

私はSpringにデバッグモードがあることを知りました。このモードでは、自動設定に関する洞察が得られます。サーバーの場合、アプリケーションパラメータとして--debugを渡すことで有効にすることができます。Springの自動構成レポートをテストで有効にする方法は?

SpringJUnit4ClassRunnerで実行される)テストにもデバッグモードを有効にする方法はありますか?


自動構成レポートが動作している場合、それはこのようないくつかの出力を印刷する必要があります:

========================= 
AUTO-CONFIGURATION REPORT 
========================= 


Positive matches: 
----------------- 

    ConfigServiceBootstrapConfiguration#configServicePropertySource matched 
     - matched (OnPropertyCondition) 

    ConfigurationPropertiesRebinderAutoConfiguration matched 
     - @ConditionalOnBean (types: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor; SearchStrategy: all) found the following [org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor] (OnBeanCondition) 

    ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesBeans matched 
     - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesBeans; SearchStrategy: current) found no beans (OnBeanCondition) 

    ConfigurationPropertiesRebinderAutoConfiguration#configurationPropertiesRebinder matched 
     - @ConditionalOnMissingBean (types: org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; SearchStrategy: current) found no beans (OnBeanCondition) 

    EncryptionBootstrapConfiguration matched 
     - @ConditionalOnClass classes found: org.springframework.security.crypto.encrypt.TextEncryptor (OnClassCondition) 

    PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer matched 
     - @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) found no beans (OnBeanCondition) 


Negative matches: 
----------------- 

    ConfigServiceBootstrapConfiguration.RetryConfiguration did not match 
     - required @ConditionalOnClass classes not found: org.springframework.retry.annotation.Retryable,org.aspectj.lang.annotation.Aspect (OnClassCondition) 

    DiscoveryClientConfigServiceBootstrapConfiguration did not match 
     - @ConditionalOnProperty missing required properties spring.cloud.config.discovery.enabled (OnPropertyCondition) 

    EncryptionBootstrapConfiguration.RsaEncryptionConfiguration did not match 
     - @ConditionalOnClass classes found: org.springframework.security.rsa.crypto.RsaSecretEncryptor (OnClassCondition) 
     - Keystore nor key found in Environment (EncryptionBootstrapConfiguration.KeyCondition) 

    EncryptionBootstrapConfiguration.VanillaEncryptionConfiguration did not match 
     - required @ConditionalOnMissing classes found: org.springframework.security.rsa.crypto.RsaSecretEncryptor (OnClassCondition) 

    EurekaDiscoveryClientConfigServiceBootstrapConfiguration did not match 
     - @ConditionalOnClass classes found: org.springframework.cloud.config.client.ConfigServicePropertySourceLocator (OnClassCondition) 
     - @ConditionalOnProperty missing required properties spring.cloud.config.discovery.enabled (OnPropertyCondition) 


Exclusions: 
----------- 

    None 


Unconditional classes: 
---------------------- 

    None 

答えて

15

--debugは、自動コンフィギュレーションレポートに切り替えdebugプロパティを設定します。たとえば、テストクラスで@TestPropertySourceを使用して同じテストを行うことができます。

@RunWith(SpringJUnit4ClassRunner.class) 
@SpringApplicationConfiguration(Application.class) 
@TestPropertySource(properties = "debug=true") 
public class YourTests { 
    // … 
} 
関連する問題