An OpenFuture project |
Log4Unit is a JUnit extension combining JUnit with Log4J. The intention is to create test protocols for JUnit.
JUnit is asymmetrical in the sense that it focusses on the documentation of test failures and errors. Successful execution of a test case is not further documented. In order to obtain a test protocol that documents the initial settings, the test case execution and its results, a logging component is required. Log4J as the current de facto standard is selected for this extension.
The current version is 0.2.0 is available for download as log4unit-0.2.0.tar.gz and log4unit-0.2.0.zip.
It is provided under GNU Lesser General Public License.
junit.framework.TestCase
does not contain any methods for
logging. Hence, the subclass junit.log4j.LoggedTestCase
is introduced
providing methods for logging:
In order to configure the logging, place a log4j.properties file in your classpath. If Log4J is not present, the console is used for logging.
Hint: Please be aware, that assertions are not logged via Log4J, since LoggedTestCase does *not* override the assert... methods of TestCase.
junit.swingui.TestRunner
is extended by junit.logswingui.TestRunner
providing the ability to view and save test protocols. In order to
write logging results to this protocol, configure
junit.log4j.JUnitAppender
as Log4J
appender in your Log4J configuration. Here an
example configuration:
------------------------------------------------------------------------------------- # junit is set to be a junit.logswingui.LoggedTestResult log4j.appender.junit=junit.log4j.JUnitAppender # junit uses PatternLayout. log4j.appender.junit.layout=junit.log4j.JUnitLayout log4j.appender.junit.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} - %m %T%n -------------------------------------------------------------------------------------
junit.log4j.LoggedTestCase
info()
,
debug()
, ... methods.log4j.properties
somewhere in the class path. This
file contains the Log4J configuration.log4j
JAR to your classpathjava junit.logswingui.TestRunner [-noloading] [TestCase]
DEBUG - Log4J successfully instantiated
.assert...()
methods are not extended, i.e. messages generated by
assert...()
methods are NOT written to the log files.
Use debug()
, info()
, warn()
or fatal()
instead.
junit.logswingui.TestRunner
.
stdout
.
Version 0.1.2: log4unit-0.1.2.tar.gz, log4unit-0.1.2.zip.