[GRADLE-2524] JAVA PLUGIN - test task - Setting of logger (using java.util.logging) is reset to defaults inside the test method (using TestNG) Created: 19/Oct/12 Updated: 12/May/16 Resolved: 12/May/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.2 |
Fix Version/s: | 2.14-rc-1 |
Type: | Bug | ||
Reporter: | Filip Brychta | Assignee: | Pepper Lebeck-Jobe |
Resolution: | Fixed | Votes: | 8 |
Attachments: | sampleJavaProject.tar.gz | ||||||||||||
Issue Links: |
|
Description |
When logging from some test method (method annotated with @Test), setting of used logger is reset to defaults. So a default formatting is used and only INFO level and higher is logged. When logging from any other place in code (other than methods annotated with @Test), expected logging output is shown. I attached a sample Java project to show the issue. You can see from following output that in @BeforeSuite method all log levels are logged and log level of Root logger is set to FINEST. However in @Test method, only WARNING and SEVERE levels are logged and log level of Root logger is set to INFO. Please see attached Java project for details. Actual output:
My test > myPackage.tests.MyTest.testMethod STANDARD_ERROR My test > myPackage.tests.MyTest.testMethod STANDARD_OUT |
Comments |
Comment by Szczepan Faber [ 22/Oct/12 ] |
Thanks for the detailed report. This is related to The problem is that in TestNG, we start redirecting the output when the test starts. @BeforeSuite is triggered before the test starts and hence, its output is handled completely differently than typical test output. This is a valid bug and we plan to fix it at some point. What is the use case you are trying to solve? Perhaps we can find a workaround? |
Comment by Szczepan Faber [ 22/Oct/12 ] |
Possible duplicates |
Comment by Filip Brychta [ 22/Oct/12 ] |
We found 2 possible workarounds:
|
Comment by Szczepan Faber [ 22/Oct/12 ] |
How do the workarounds work for you? |
Comment by Filip Brychta [ 23/Oct/12 ] |
#2 'Overwrite test task and use Ant for launching tests' is fine for us. So it's not a blocker for us, but we are planning to return to standard 'test' task once this issue is fixed. |
Comment by Uladzimir Mihura [ 30/May/13 ] |
It's true for a JUnit too:
LogManager.getLogManager().reset();
Logger.getLogger("").addHandler(new ConsoleHandler());
-vova |
Comment by Dmitriy Korobskiy [ 30/May/13 ] |
Have the same issue with JUnit. Discussed on the forum: http://forums.gradle.org/gradle/topics/unable_to_configure_java_util_logging_with_gradle_test_task |
Comment by Gary Hale [ 01/Apr/16 ] |
This has been reverted from 2.13 because it can break tests that rely on the old behavior. We will reintroduce for 2.14 with a toggle to enable the old/new behavior. |