There are two tasks Check Task and CheckPrevious Task.
The Check task allows you to check a predefined value in a report. For example, check that the code coverage value in a code coverage report is at least 80 %.
The CheckPrevious task allows you to check that a result from the latest build hasn't deteriorated since the last successful build. For instance you can check that a performance metric has not deteriorated.
Tools supported are currently cobertura, clover, jmeter, findbugs, pmd, junit and generic.
The nested xmlcatalog element is supported for both tasks.
Ensure that cathcart-ant-tasks-x.x.x.jar is in ant's classpath.
Add antlib declaration to the project tag of your build file:
<project name="myproject" xmlns:cathcart="antlib:net.sourceforge.cathcart" default="my.default.target">
or add typedef declarations:
<typedef resource="cathcart_taskdefs.properties" classpath="${ant.home}/lib/cathcart-ant-tasks-x.x.x.jar" /> <typedef resource="cathcart_typedefs.properties" classpath="${ant.home}/lib/cathcart-ant-tasks-x.x.x.jar" />
Checks if a metric in an xml report is within specified limits. eg.
Attribute | Description | Required |
inXml | report containing the metrics to compare | Yes |
tool | Name of the tool used to produce the metrics report. A corresponding xsl stylesheet cathcart-[tool].xsl must be in ant's classpath. | Valid values: cobertura, clover, jmeter, findbugs, pmd, junit and generic |
haltonfailure | Stop the build process if the check fails | No, default is true |
The nested propertytype element specifies the name of the property and the limits it is to be checked against.
Attribute | Description | Required |
name | The name of the property to check. | Yes. Valid values for cobertura are branchrate and linerate. Valid values for clover are conditionalsrate, coveragerate, statementsrate and methodsrate. Valid values for jmeter are maxtime, averagetime, successpercent and failurecount. Valid values for findbugs are totalbugs. Valid values for pmd are violations. Valid values for junit are failures, errors, skipped and test. Valid values for generic are downward and upward. |
limit | The limit value. | Yes |
leeway | The amount of leeway which is allowed. This is specified as a percentage unless the "absolute" parameter is set true. | No, default is 0 |
absolute | Treat the leeway as an absolute amount, otherwise as a percentage. | No, default is false |
If multiple propertytype nested elements are specified then the build will fail if any of them is not fullfilled.
<cathcart:check tool="cobertura" inxml="${cobertura.report}"> <cathcart:propertytype name="coveragelinerate" limit="13.88"/> </cathcart:check>
Compares a value in an xml report to a value from a previous successful build.
Attribute | Description | Required |
inXml | report containing the metrics to compare | Yes |
tool | Name of the tool used to produce the metrics report. A corresponding xsl stylesheet cathcart-[tool].xsl must be in ant's classpath. | Yes. Valid values: cobertura, clover, jmeter, findbugs, pmd, junit and generic. |
haltonfailure | Stop the build process if the check fails | No, default is true |
storeDir | directory where results are saved between builds | No, default is previous |
outXml | Name of file that stores result when successful | No, default is cathcart_[tool].xml |
backup | Make a backup of the last outXml file by appending the current time to its name | No, default is true |
The nested propertytype element specifies the name of the property that is to be checked against.
Attribute | Description | Required |
name | The name of the property to check. | Yes. Valid values for cobertura are branchrate and linerate. Valid values for clover are conditionalsrate, coveragerate, statementsrate and methodsrate. Valid values for jmeter are maxtime, averagetime, successpercent and failurecount. Valid values for findbugs are totalbugs. Valid values for pmd are violations. Valid values for junit are failures, errors, skipped and test. Valid values for generic are downward and upward. |
leeway | The amount of leeway which is allowed. This is specified as a percentage unless the "absolute" parameter is set true. | No, default is 0 |
absolute | Treat the leeway as an absolute amount, otherwise as a percentage. | No, default is false |
In addition to examples of usage in these task descriptions, there are copious examples in the build_test.xml file.
Support for other tools can easliy be added:
Create a stylesheet cathcart-[tool].xsl to extract the properties you want to check eg cathcart-clover.xsl. Add the stylesheet to cathcart-ant-tasks-x.x.x.jar This stylesheet must create a result like this:
<clover> <statementsrate>87.95986622073579</statementsrate> <methodsrate>86.48648648648648</methodsrate> <conditionalsrate>90</conditionalsrate> <coveragerate>88.03611738148985</coveragerate> </clover>
The root element has the same name as the tool. The nested tags are named after the properties to be checked.
Add the tool configuration to the tools_config.xml which is contained in the cathcart-ant-tasks.jar. For example:
<tools> ... <tool> <tool> <cobertura url="http://cobertura.sourceforge.net/"> <nestedproperties> <linerate trend="upward" /> <branchrate trend="upward" /> </nestedproperties> </cobertura> </tool> ... </tools>
This specifies this tool name and the available properties (corresponding to the names created by the xsl file) and the desired trend. For example, the desired trend for coverage rates is upward whilst that for failure counts is downward.
Feel free to submit your xsl template for inclusion in future releases of cathcart.
Colonel Cathcart is a character from Joseph Heller's novel Catch 22, responsible for a bomber squadron during WW2. He sets the target number of missions his men must fly before they are eligible to be sent home. But everytime Yossarian (the hero of the novel) looks like achieving this target, Cathcart raises it.