Plugin Mechanism

Log4Testing allows the user to write and plug in custom extensions. Each extension point has a base name (in the following example 'xyz') that identifies which type of extension is to be plugged in. It must have a <class> element as child which specifies the fully qualified name of the class. An optional <properties> child element serves for setting JavaBean properties of the plugin object, similar to the <sysprops> structure described above.

Note: Currently the mechanism is limited to String-type properties!

The value of Java system and OS environment variables can be included using ${variable_name}.

Example:

<xyz>
   <class>org.aludratest.log4testing.core.output.writer.VelocityTestCaseWriter</class>
   <properties>
       <template>org/aludratest/impl/log4testing/core/output/html/testCase.vm</template>
       <extension>html</extension>
       <variable>testCase</variable>
       <outputdir>${log4testing_outputdir}</outputdir>        
   </properties>
</xyz>

Configuring TestObservers

TestObservers are plugged in to get notified of test status changes and react according to their purpose. Log4Testing makes use of TestObservers for generating its HTML and XML reports and report the number of tests remaining. Each TestObserver is declared as a single <observer> element inside an <observers> under the XML root node:

<log4testing>
...
<observers>
    <observer>
        <class>com.my.MyObserver1</class>
        <properties>
            ...
        </properties>
    </observer>
    <observer>
        <class>com.my.MyObserver2</class>
        <properties>
            ...
        </properties>
    </observer>
</observers>

HTMLReportObserver

The HTMLReportObserver employs Velocity templates for generating recursive HTML reports of all test suites and test cases. It is plugged in using the following example configuration:

<observer>
   <class>org.aludratest.impl.log4testing.core.observer.HTMLReportObserver</class>
   <properties>
       <testCaseTemplate>org/aludratest/impl/log4testing/core/output/html/testCase.vm</testCaseTemplate>
       <testSuiteTemplate>org/aludratest/impl/log4testing/core/output/html/testSuite.vm</testSuiteTemplate>
       <outputdir>${log4testing_outputdir}/html</outputdir>        
       <ignoreableRoot>my.company.testcases</ignoreableRoot>
       <abbreviating>true</abbreviating>
       <shortTimeFormat>true</shortTimeFormat>
       <openBrowser>false</openBrowser>
   </properties>
</observer>

The possible settings are as follows:

SettingDescription
testCaseTemplateThe path of the Velocity template file to use for rendering a test case
testSuiteTemplateThe path of the Velocity template file to use for rendering a test suite
outputdirThe folder in which to put the generated files
ignoreableRootCommon root package name of the test cases to be ommotted from test file paths and names
abbreviatingboolean flag (true/false) to specify if file paths should be abbreviated. This affects only the file paths, not the test suite and test case names. Abbreviations are defined as key-value-pairs in a file named abbreviations.properties. The key parts define text parts to be abbreviated and the value parts the texts to be used as abbreviation.
shortTimeFormatboolean flag (true/false) to specify if a short (hh:mm:ss'ms) or long (# days # hours # minutes # seconds # milliseconds) date format shall be used.
openBrowserboolean flag (true/false) to specify if the system's default browser shall be opened with the root suite report. This is done when test execution has finished.

XMLReportObserver

The XMLReportObserver works similar to the HTMLReportObserver (has the same settings), but renders parseable XML instead of HTML. This can be used for post-processing of the test results.

PendingTestsObserver

The PendingTestsObserver prints out the current number of tests pending after each test step that has been finished.

Configuration File Example

A typical log4testing.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<log4testing>
   <sysprops>
       <log4testing_outputdir>target/log4testing</log4testing_outputdir>
   </sysprops>
   <observers>
       <observer>
           <class>org.aludratest.impl.log4testing.core.observer.HTMLReportObserver</class>
           <properties>
               <testCaseTemplate>org/aludratest/impl/log4testing/core/output/html/testCase.vm</testCaseTemplate>
               <testSuiteTemplate>org/aludratest/impl/log4testing/core/output/html/testSuite.vm</testSuiteTemplate>
               <outputdir>${log4testing_outputdir}/html</outputdir>        
               <ignoreableRoot>com.mycompany.testcases</ignoreableRoot>
               <abbreviating>true</abbreviating>
               <shortTimeFormat>true</shortTimeFormat>
           </properties>
       </observer>
       <observer>
           <class>org.aludratest.impl.log4testing.core.observer.PendingTestsObserver</class>
       </observer>
       <observer>
           <class>org.aludratest.impl.log4testing.core.observer.XMLReportObserver</class>
           <properties>
               <testSuiteTemplate>org/aludratest/impl/log4testing/core/output/html/testSuiteXML.vm</testSuiteTemplate>
               <outputdir>${log4testing_outputdir}/xml</outputdir>        
           </properties>
       </observer>
   </observers>
</log4testing>