[
https://issues.apache.org/jira/browse/WINK-261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12844615#action_12844615
]
Mike Rheinheimer commented on WINK-261:
---------------------------------------
Committed in 922389.
There are two changes in this commit:
1) If you desire to turn on debug logging in maven build of the whole tree or
of a particular component, you only need to add a param to your mvn command
line:
mvn -Djava.util.logging.config.file=/full/path/to/logging.properties
There is a default properties file at
wink-component-test-support/src/main/resources/logging.properties.
The log output goes into the respective
target/surefire-reports/*-output.txt files.
To perform the same in Eclipse, pass
-Djava.util.logging.config.file=/full/path/to/logging.properties in the JVM
args field
in the Run dialog box. You'll get output in the *-output.txt files and on
the Eclipse console.
2) If you desire to capture debug output in a specific unittest method to
perform asserts on the log output itself, you can now do so! You can write a
test like so:
public void testLogging() throws Exception {
WinkLogHandler.turnLoggingCaptureOn(); // WinkLogHandler imported from
wink-component-test-support module
ApplicationFileLoader applicationFileLoader =
new ApplicationFileLoader("application//custom.app");
WinkLogHandler.turnLoggingCaptureOff();
ArrayList<LogRecord> logRecords = WinkLogHandler.getRecords();
assertEquals(14, logRecords.size());
WinkLogHandler.clearRecords(); // recommend doing this so static
ArrayList of LogRecords is clear for next test
}
I'll duplicate these instructions to the dev email list.
> Add way to be able to capture logging warnings in unit tests so we can
> correctly identify when messages are correctly being emitted
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: WINK-261
> URL: https://issues.apache.org/jira/browse/WINK-261
> Project: Wink
> Issue Type: Improvement
> Components: Testsuite
> Reporter: Bryant Luk
> Assignee: Mike Rheinheimer
> Fix For: 1.0, 1.1
>
>
> It would be nice if we had a way to capture the slf4j logs while running a
> unit test so that we can later add assertions that certain warnings were
> correctly made. Not sure the best approach or if there's an easy
> pre-existing solution.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.