8.3.5 Variation Renderer

QuickBuild 2.0 Documentation

Variation renderer is used to compare to the report generated from the previous build. For example, for test reports, we want to know how many tests have been added, how many tests have been fixed, and how many tests still haven't been fixed.

ScreenShot: JUnit Overview

Following is a common variation definition which is part of the JUnit plugin setting:

<renderer type="variation" title="Overview" source="testcase" lastSuccessful="false">
    <status>currentStatus = current.getValue("status");
            previousStatus = previous.getValue("status");
            if (!currentStatus.equals(previousStatus)) {
               if (currentStatus.equals("success"))
                    return "Fixed Tests"
                else return "New Failed Tests";
             } else {
                if (!currentStatus.equals("success"))
                   return "Not Fixed Tests";
                 else
                   return null;
             }
    </status>
    <childTitle>${if (status.equals("New")) return "New Added Tests";
                  else if (status.equals("Removed")) return "Removed Tests";
                  else return status;}</childTitle>
    <field source="name" title="Total Tests"/>
    <field source="time" title="Total Duration"/>
        
    <renderer type="table">
	    <column type="Id"/>
	    <column type="Enum" title="Status" sortBy="status">
	      <field source="status" title="Status"/>
	    </column>
	    <column type="Text" title="Test Case" sortBy="classname" escape="false">
	      <field>
	        <expression><![CDATA[
	            <h3 style="color:#333;">${getValue("name")}</h3>
	            <p style="color:#666;">In: ${getValue("classname")}</p>
	        ]]></expression>
	      </field>
	    </column>
	    <column type="Text" title="Duration" sortBy="time">
	      <field source="time" title="Duration"/>
	      <dropdown type="stats" source="time" maxBuilds="10"/>
	    </column>
   </renderer>
</renderer>

'status' Element

The 'status' element is the core for variation renderer which tell the renderer how to distinguish the difference between current report and previous report. By default, QuickBuild only has "New", "Removed", and "Changed" and "UnChanged" status of each row. And via 'status' element, arbitary status can be set via expression. The context of the expression is 'current' and 'previous' which means the row of current report and previous report.
The 'New' added rows in current report, the 'Removed' rows will be detected by QuickBuild automatically, and other status can be set via the expression. For those rows which needn't be considered, just return null and QuickBuild will omit those rows.
The "UnChanged" status in QuickBuild is on condition that all values in current row and previous row are identical, and QuickBuild will omit those rows. If this condition is too strict, then use the expression instead. For example, we only consider the tests in current report and previous report are same when the status in both are same, then we can do like:

<status>if (current.getValue("status").equals(previous.getValue("status")) return null; 
        else return "Status Changed";
</status>

'showStatus'

The attribute(/element) in the renderer is used to detect which status will be rendered. For example:

<renderer type="variation" showStatus="New Added Tests, Fixed Tests, Not Fixed Tests">
...
</renderer>

When there are multiple status should be displayed, use comma ',' to separate them.
If this attribute hasn't been defined, then all valid status will be displayed.

'childTitle' Element

The variation renderer will render different sections by iterating all displayable status. By default, the title will use the status. By defining the 'childTitle' element, arbitrary title can be specified via using interpolate string.

'field' Element

The 'field' element is used to add a statistics scorecard item. The 'source' attribute should be defined in the report meta data.

'renderer' Element

Variation renderer need one 'renderer' element to render the each section.

Labels

 
(None)