Scott_D
(Scott Duchin)
October 22, 2014, 9:07pm
1
this is an example test:
@Test
public void logDebug() {
logger.fine("DEBUG");
logger.info("INFO");
assertNull(logger);
}
this is the standard error:
Oct 13, 2014 9:59:02 AM com.motorola.base.util.LoggerUtilTest logDebug
INFO: [INFO]
I am unable to get the DEBUG statement to print out.
I have tried: 1)
test {
logging.setLevel(LogLevel.DEBUG)
}
test {
jvmArgs "-Djava.util.logging.config.file=~/storm/resourcestest/com/motorola/logging.properties"
}
gradle -Djava.util.logging.config.file=~/storm/resourcestest/com/motorola/logging.properties test
none of these plus some other variations have not worked
this is causing many developers not to use logger.fine() but instead logger.info () just to get logger results while testing. this needs to be fixed as it is impacting proper coding techniques.
Does this help?
test {
systemProperty "java.util.logging.config.file", "~/storm/resourcestest/com/motorola/logging.properties"
}
Scott_D
(Scott Duchin)
October 22, 2014, 10:15pm
3
no, still got:
Oct 22, 2014 3:12:49 PM com.motorola.base.util.LoggerUtilTest logDebug
INFO: [INFO]
Do you see the log output in the HTML test report?
Scott_D
(Scott Duchin)
October 22, 2014, 10:47pm
5
the output was under the junit screen results under “standard errors”
Do you see the debug log output on the console after adding ‘test.testLogging.showStandardStreams = true’?
Scott_D
(Scott Duchin)
October 23, 2014, 8:49pm
7
no, i do not see anything on console
com.motorola.base.util.LoggerUtilTest > logDebug FAILED
java.lang.AssertionError at LoggerUtilTest.java:34
19 tests completed, 1 failed
:storm:javatestsComMotorolaBaseUtilTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':storm:javatestsComMotorolaBaseUtilTest'.
> There were failing tests. See the report at: file:///Users/me/storm/moto1/build/storm/reports/tests/javatestsComMotorolaBaseUtil/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Scott_D
(Scott Duchin)
October 23, 2014, 8:51pm
8
test {
forkEvery = 100
ignoreFailures = false
maxParallelForks = Math.max(2, Runtime.runtime.availableProcessors() - 2)
reports.html.enabled = true
testLogging {
exceptionFormat 'full'
}
test.testLogging.showStandardStreams = true
// tried once with this commented and uncommented
systemProperty "java.util.logging.config.file",
"${System.env.MOTO1}/resourcestest/com/motorola/logging.properties"
}
Scott_D
(Scott Duchin)
October 23, 2014, 8:56pm
9
by the way, i ran things with --debug and i still do not see the expected line
13:53:41.769 [QUIET] [system.out] 13:53:41.769 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class com.motorola.base.util.LoggerUtilTest
13:53:41.770 [DEBUG] [TestEventLogger]
13:53:41.770 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest STARTED
13:53:41.813 [DEBUG] [TestEventLogger]
13:53:41.814 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest > logDebug STARTED
13:53:41.832 [DEBUG] [TestEventLogger]
13:53:41.833 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest > logDebug STANDARD_ERROR
13:53:41.833 [DEBUG] [TestEventLogger]
Oct 23, 2014 1:53:41 PM com.motorola.base.util.LoggerUtilTest logDebug
13:53:41.833 [DEBUG] [TestEventLogger]
INFO: [INFO]
13:53:41.837 [QUIET] [system.out] 13:53:41.837 [DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class com.motorola.base.util.MapSortTest
13:53:41.854 [DEBUG] [TestEventLogger]
13:53:41.855 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest > logDebug FAILED
13:53:41.855 [DEBUG] [TestEventLogger]
java.lang.AssertionError: expected null, but was:<java.util.logging.Logger@38cc7c87>
13:53:41.855 [DEBUG] [TestEventLogger]
at org.junit.Assert.fail(Assert.java:88)
13:53:41.856 [DEBUG] [TestEventLogger]
at org.junit.Assert.failNotNull(Assert.java:664)
13:53:41.856 [DEBUG] [TestEventLogger]
at org.junit.Assert.assertNull(Assert.java:646)
13:53:41.856 [DEBUG] [TestEventLogger]
at org.junit.Assert.assertNull(Assert.java:656)
13:53:41.856 [DEBUG] [TestEventLogger]
at com.motorola.base.util.LoggerUtilTest.logDebug(LoggerUtilTest.java:34)
13:53:41.857 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:53:41.857 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
13:53:41.857 [DEBUG] [TestEventLogger]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
13:53:41.857 [DEBUG] [TestEventLogger]
at java.lang.reflect.Method.invoke(Method.java:606)
13:53:41.858 [DEBUG] [TestEventLogger]
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
13:53:41.858 [DEBUG] [TestEventLogger]
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
13:53:41.858 [DEBUG] [TestEventLogger]
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
13:53:41.858 [DEBUG] [TestEventLogger]
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
13:53:41.858 [DEBUG] [TestEventLogger]
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
13:53:41.859 [DEBUG] [TestEventLogger]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
13:53:41.859 [DEBUG] [TestEventLogger]
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
13:53:41.859 [DEBUG] [TestEventLogger]
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
13:53:41.859 [DEBUG] [TestEventLogger]
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
13:53:41.859 [DEBUG] [TestEventLogger]
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
13:53:41.860 [DEBUG] [TestEventLogger]
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
13:53:41.860 [DEBUG] [TestEventLogger]
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
13:53:41.860 [DEBUG] [TestEventLogger]
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
13:53:41.860 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
13:53:41.861 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
13:53:41.861 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
13:53:41.861 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
13:53:41.861 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:53:41.862 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
13:53:41.862 [DEBUG] [TestEventLogger]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
13:53:41.862 [DEBUG] [TestEventLogger]
at java.lang.reflect.Method.invoke(Method.java:606)
13:53:41.862 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
13:53:41.863 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
13:53:41.863 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
13:53:41.863 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
13:53:41.864 [DEBUG] [TestEventLogger]
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
13:53:41.864 [DEBUG] [TestEventLogger]
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
13:53:41.864 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:53:41.864 [DEBUG] [TestEventLogger]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
13:53:41.865 [DEBUG] [TestEventLogger]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
13:53:41.865 [DEBUG] [TestEventLogger]
at java.lang.reflect.Method.invoke(Method.java:606)
13:53:41.865 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
13:53:41.865 [DEBUG] [TestEventLogger]
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
13:53:41.866 [DEBUG] [TestEventLogger]
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
13:53:41.866 [DEBUG] [TestEventLogger]
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
13:53:41.866 [DEBUG] [TestEventLogger]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
13:53:41.867 [DEBUG] [TestEventLogger]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
13:53:41.867 [DEBUG] [TestEventLogger]
at java.lang.Thread.run(Thread.java:745)
13:53:41.867 [DEBUG] [TestEventLogger]
13:53:41.868 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest > logRecord_minimum STARTED
13:53:41.868 [DEBUG] [TestEventLogger]
13:53:41.868 [QUIET] [system.out] 13:53:41.868
13:53:41.868 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest > logRecord_minimum PASSED
13:53:41.869 [QUIET] [system.out]
[DEBUG] [org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor] Executing test class com.motorola.base.util.MapUtilTest
13:53:41.869 [DEBUG] [TestEventLogger]
13:53:41.869 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest > logRecord_full STARTED
13:53:41.870 [DEBUG] [TestEventLogger]
13:53:41.870 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest > logRecord_full PASSED
13:53:41.870 [DEBUG] [TestEventLogger]
13:53:41.870 [DEBUG] [TestEventLogger] com.motorola.base.util.LoggerUtilTest FAILED
13:53:41.871 [DEBUG] [TestEventLogger]
13:53:41.871 [DEBUG] [TestEventLogger] com.motorola.base.util.MapSortTest STARTED
Scott_D
(Scott Duchin)
November 12, 2014, 12:35am
10
any update on this? this is blocking us from using logger.debug as we cannot view the output in tests