2014-12-04 74 views
0

我使用gradle作爲構建工具,用於spring引導應用程序,在那裏我遇到了一些奇怪的行爲。 Gradle顯示了更多的關於明確關閉測試輸出的日誌信息,就像我沒有指定任何東西一樣。gradle:禁用輸出顯式導致詳細輸出

這很奇怪,因爲顯式的禁用語句應該至少與沒有配置一樣具有表現力,或者不應該這樣做?

例子: 如果我下面的行添加到我的的build.gradle,我得到的運行gradle test一個通過更爲詳細的日誌輸出:

test{ 
    testLogging { 
     showStackTraces = false 
     showStandardStreams = false 
     showExceptions = false 
     showCauses = false 
     events "failed" 
     exceptionFormat "short" 
    } 
} 

編輯:

我按@Peter_Niederwieser的建議將其更改爲events = []。現在幾乎所有的消息都消失了,除了下面的消息。有人或其他想法我怎麼能壓制他們?我只想顯示結果34 tests completed,並可能指向報告的鏈接。

:backend:test 
Download http://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.pom 
Download http://repo1.maven.org/maven2/org/jacoco/org.jacoco.build/0.6.2.201302030002/org.jacoco.build-0.6.2.201302030002.pom 
Download http://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.jar 
objc[1360]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined. 
08:50:37.135 [Thread-7] INFO o.s.c.s.GenericApplicationContext - Closing [email protected]8186d4: startup date [Sat Dec 06 08:50:35 CET 2014]; root of context hierarchy 
08:50:37.135 [Thread-6] INFO o.s.c.s.GenericApplicationContext - Closing [email protected]18a206: startup date [Sat Dec 06 08:50:35 CET 2014]; root of context hierarchy 
08:50:37.135 [Thread-5] INFO o.s.c.s.GenericApplicationContext - Closing [email protected]21dfe5: startup date [Sat Dec 06 08:50:35 CET 2014]; root of context hierarchy 
08:50:37.135 [Thread-8] INFO o.s.w.c.s.GenericWebApplicationContext - Closing org.s[email protected]5a5fbef7: startup date [Sat Dec 06 08:50:36 CET 2014]; root of context hierarchy 
08:50:37.166 [Thread-7] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor' 
08:50:37.166 [Thread-6] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor' 
08:50:37.167 [Thread-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor' 
08:50:37.167 [Thread-8] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor' 
08:50:37.167 [Thread-7] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.s[email protected]65bad9fe: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,testConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor]; root of factory hierarchy 
08:50:37.168 [Thread-6] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.s[email protected]c355f75: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,testConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor]; root of factory hierarchy 
08:50:37.168 [Thread-5] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.s[email protected]6dd79791: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,testConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor]; root of factory hierarchy 
08:50:37.168 [Thread-8] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Destroying singletons in org.s[email protected]75a5ec9: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.co                                            ntext.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,testConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor]; root of factory hierarchy 
08:50:37.175 [Thread-7] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'testConfig' 
08:50:37.175 [Thread-6] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'testConfig' 
08:50:37.176 [Thread-5] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'testConfig' 
08:50:37.176 [Thread-8] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'testConfig' 

34 tests completed, 9 failed 
:backend:test FAILED 

回答

1

默認爲events = []。上面的代碼設置爲events "failed",這將導致更詳細的日誌記錄(每個失敗的測試將單獨記錄)。

+0

嗨,謝謝!這真的很有幫助,但仍然有一些日誌輸出。我更新了我的問題,你有什麼建議嗎? – NaN 2014-12-06 08:02:01

+0

不知道爲什麼你仍然會看到這個,但是嘗試將一個日誌記錄配置文件(用於你的應用程序的日誌記錄框架)放到'src/test/resources'中,以關閉所有的日誌記錄。如果升級到最新的Gradle版本有所作爲,您也可以嘗試。 – 2014-12-07 00:47:19

+0

應用程序日誌設置爲DEBUG,我想保留這個。我只想禁用測試任務的輸出。 – NaN 2014-12-07 08:02:29