The main script-facing tasks in this package are: CaptureLogsTask (<capturelogs>), CaptureStreamsTask (<captureoutput>), AssertLoggedTask (<assertlogged>), CopyLoggedTask (<copylogged>), ClearLoggedTask (<clearlogged>), and InterpretLoggedTask (<evaluatelogged>).
This package is broken into two types of classes: LogsRecorders (captures the logged information) and Logs Users (reads and manipulates captured information). All recorders use the CapturedLogs fixture administrator to install themselves as iteration-based LogsRecorders. All log users use the CapturedLogs administrator to retrieve the nearest typed logs recorder.
CopyLoggedTask was added to allow test build scripts to support manual examination of test output or additional testing from within the JUnit test engine. As it turns out, copying logs is generally useful in build scripts for capturing warnings from other Ant tasks like javadoc, javac, etc. This means that <capturelogs> is not a "testing-only" task (unlike <assertlogged>).
Both CaptureLogsTasks and CaptureStreamsTasks can be nested; inner log recorders do not affect outer ones. By default, both <assertlogged> and <copylogged> apply to the nearest <capturelogs>. If a <captureoutput> has been installed instead of <capturelogs>, both <assertlogged> and <copylogged> can be directed to use this captured information using the common from="stdio" attribute setting (see examples below).
Example Usage:
<capturelogs> <echo message="((Warning))"/> <assertlogged value="((Warning))" trueproperty="Was.warned"/> <assert issettrue="Was.warned"/> <echo level="verbose" message="((Verbose))"/> <assertlogged value="((Verbose))" occurances="0" msg="Broken importance check"/> <assertlogged important="no" value="((Verbose))" occurances="1"/> <assertlogged important="no"> <string value="((Warning))"/> <string value="((Verbose))"/> </assertlogged> </capturelogs> Nested logs recorders: <capturelogs> <echo message="((Warning.0))"/> <assertlogged value="((Warning.0))"/> <capturelogs importantFrom="warning"> <assertlogged value="((Warning.0))" occurances="0"/> <echo level="info" message="((Info))"/> <assertlogged value="((Info)" occurances="0"/> <echo level="warning" message="((Warning.1))"/> <assertlogged value="((Warning.1))" reset="yes"/> </capturelogs> <assertlogged> <string value="((Warning.0))"/> <string value="((Info))"/> <string value="((Warning.1))"/> </assertlogged> </capturelogs> Capturing System.err or System.out: <captureoutput from="stderr"> <script .../> <copylogged from="stdio" tofile="${logs}/script.err/> </captureoutput>