Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0-RC3
-
Fix Version/s: None
-
Component/s: Testing
-
Labels:None
-
Environment:Hidejava version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
Linux cbedford-laptop 2.6.38-10-generic-pae #46-Ubuntu SMP Tue Jun 28 16:54:49 UTC 2011 i686 i686 i386 GNU/Linux
Showjava version "1.6.0_27" Java(TM) SE Runtime Environment (build 1.6.0_27-b07) Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode) Linux cbedford-laptop 2.6.38-10-generic-pae #46-Ubuntu SMP Tue Jun 28 16:54:49 UTC 2011 i686 i686 i386 GNU/Linux
-
Testcase included:yes
Description
The attached sample application illustrates the problem. Basically, I have a simple class defined as below in "Class with logger output":
When I invoke the printLogMsg() of this class from a controller (by running the app and going to the
following URL: http://localhost:8080/books/book/list), I see the following logging messages associated with the Bounce class:
2011-12-07 01:04:10,807 ["http-bio-8080"-exec-4] INFO lackey.Bounce - – info booobounce
| Error 2011-12-07 01:04:10,809 ["http-bio-8080"-exec-4] ERROR lackey.Bounce - booobounce |
as expected...
I have three tests which also invoke new Bounce().printLogMsg() and I have found that only the
integration test produces logging output when run.
The two unit tests fail to produce any logging output at all.
when I bring up the test reports in target/test-reports I see the output for the two tests reported as follows:
System output
MSG
bounzzzwwwwwwwwwwwwwcing
This is only println output, not logging output is present.
Also, there is NO CONSOLE OUTPUT containing the expected logging statements when these tests are run with test-app -unit.
Finally, just to make sure that the logging statements were simply not showing up in the web report i did the following command:
grep -R booobounce .
in the top level directory.. and this revealed no test output with the exepected logging statements.
Class with logger output
>>>>
package com.lackey
import org.apache.log4j.Logger;
class Bar {
private static org.apache.log4j.Logger loggie = Logger.getLogger(com.lackey.Bar.class)
void printLogMsg()
{ loggie.info("HO HOHO logger info") loggie.error("HO HOHO logger error") println ">>println not logger output" }}
The two unit tests are defined as below (note one is derived from junit TestCase, and the other from GrailsUnitTestCase, just in case that made a difference – it did not)
package com.blah
import grails.test.*
class GrailsUnitTestCaseBookTests extends GrailsUnitTestCase {
protected void setUp()
protected void tearDown() { super.tearDown() }
void testSomething() { println "MSG" new com.lackey.Bounce().message() }
}
package com.blah
import grails.test.GrailsUnitTestCase
import junit.framework.TestCase
class PlainJunitTestCaseBookTests extends TestCase {
protected void setUp() { super.setUp() }
protected void tearDown()
{ super.tearDown() }void testSomething()
{ println "MSG" new com.lackey.Bounce().message() }}
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits