PHPackages                             micheh/teamcity-clover - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. micheh/teamcity-clover

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

micheh/teamcity-clover
======================

Parse the clover.xml and report the code coverage and CRAP indices to TeamCity

0.7(7y ago)11435.8k—3.1%9BSD-3-ClausePHPPHP &gt;=5.2.0

Since Oct 17Pushed 7y ago3 watchersCompare

[ Source](https://github.com/micheh/teamcity-clover)[ Packagist](https://packagist.org/packages/micheh/teamcity-clover)[ RSS](/packages/micheh-teamcity-clover/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (8)Used By (0)

Clover.xml parser for TeamCity
==============================

[](#cloverxml-parser-for-teamcity)

This small php script integrates the code coverage information from PHPUnit into TeamCity. The script uses [service messages](https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity) to notify TeamCity of the build metrics (since usage of `teamcity-info.xml` has been deprecated, and support may be removed in future versions of TeamCity).

The metrics will appear in the TeamCity GUI by default (under the Overview tab for a specific build and under the Statistics tab for your build configuration). As of TeamCity 9, you can easily add custom charts if your reporting needs are more sophisticated (see below).

Additionally, these metrics can be used to enforce standards on builds. For example, you can update your build configuration to enforce that code coverage has not dropped below some pre-determined threshold, or has not dropped by some percentage. See the [TeamCity documentation](https://confluence.jetbrains.com/display/TCD9/Build+Failure+Conditions#BuildFailureConditions-fail-metric-change) for more information.

Installation
------------

[](#installation)

Use composer to add teamcity-clover to your project: `composer require --dev micheh/teamcity-clover`.

Or manually add it to your `composer.json` file with:

```
"require-dev": {
    "micheh/teamcity-clover": "~0.6"
}
```

To use the script without composer, [download the current version](https://github.com/micheh/teamcity-clover/archive/master.zip) and extract the files to a location where TeamCity has access.

Usage
-----

[](#usage)

Run PHPUnit and make sure to use the `--coverage-clover` argument to create the clover.xml. Then add another build step to run the `teamcity-clover.php` script and provide the path to the clover.xml as the only argument, for example: `php path/to/teamcity-clover.php %system.teamcity.build.tempDir%/clover.xml`. If you are using the PHPUnit Meta-Runner from the [JetBrains Meta-Runner Power Pack](https://github.com/JetBrains/meta-runner-power-pack/tree/master/php), the above path is where you'll find the clover.xml.

Mapping
-------

[](#mapping)

Since TeamCity and PHPUnit do not provide the same code coverage information, the different attributes had to be matched. The code coverage mapping is as follows:

TeamCityPHPUnitStatistic Key NamesLinesElementsCodeCoverageAbsLTotal, CodeCoverageAbsLCovered, CodeCoverageLBlocksStatementsCodeCoverageAbsBTotal, CodeCoverageAbsBCovered, CodeCoverageBMethodsMethodsCodeCoverageAbsMTotal, CodeCoverageAbsMCovered, CodeCoverageMClassesClasses/TraitsCodeCoverageAbsCTotal, CodeCoverageAbsCCovered, CodeCoverageCCustom statistics
-----------------

[](#custom-statistics)

In addition to the code coverage, the script will also report custom statistic values to TeamCity. These values do not appear in the web interface by default, but can be used for custom graphs or for build failure conditions.

### CRAP Index

[](#crap-index)

PHPUnit calculates a Change Risk Anti-Patterns (CRAP) Index for each method, which depends on the cyclomatic complexity and code coverage (see [this question on StackOverflow](https://stackoverflow.com/q/4731774) for more information). The script will report the total, average, and maximum CRAP index to TeamCity, as well as the number and percentage of methods with a CRAP index equal or above a specified threshold (by default 30). You can change the CRAP threshold by providing the `--crap-threshold ` argument to the script. For example, to count all methods with a CRAP index of 20 or more, use `php teamcity-clover.php --crap-threshold 20 clover.xml`. Set the threshold to 0 to disable the reporting of the CRAP metrics.

Custom Statistic KeyDescriptionCRAPAmountNumber of methods with a CRAP index &gt;= threshold (default: 30)CRAPPercentPercentage of methods with a CRAP index &gt;= threshold (default: 30)CRAPTotalTotal CRAP index (sum of all CRAP indices)CRAPAverageAverage CRAP index over all methodsCRAPMaximumHighest CRAP index reported### Other metrics

[](#other-metrics)

In addition, the following various metrics are reported to TeamCity:

Custom Statistic KeyDescriptionFilesAmount of filesLinesOfCodeAmount of lines of codeNonCommentLinesOfCodeAmount of non-comment lines of codeCustom Graphs
-------------

[](#custom-graphs)

Besides the automatically created code coverage graphs, you can create graphs for the custom statistics as well, by updating the `/config/main-config.xml`. For example:

```

```

If you use TeamCity 9 or newer, you can also add custom graphs directly via the TeamCity web interface, instead of manually editing project XML's. See the [TeamCity documentation](https://confluence.jetbrains.com/display/TCD9/Custom+Chart) for more information.

License
-------

[](#license)

The files in this archive are licensed under the BSD-3-Clause license. You can find a copy of this license in [LICENSE.md](LICENSE.md).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~229 days

Recently: every ~235 days

Total

7

Last Release

2857d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee309938d7863c2a8209e415617207328a023b3e23ecb2d4a64c928659f05ce4?d=identicon)[micheh](/maintainers/micheh)

---

Top Contributors

[![micheh](https://avatars.githubusercontent.com/u/1307920?v=4)](https://github.com/micheh "micheh (25 commits)")[![munkie](https://avatars.githubusercontent.com/u/102297?v=4)](https://github.com/munkie "munkie (3 commits)")

---

Tags

phpunitcoverageteamcityclovercode coverageclover.xml

### Embed Badge

![Health badge](/badges/micheh-teamcity-clover/health.svg)

```
[![Health](https://phpackages.com/badges/micheh-teamcity-clover/health.svg)](https://phpackages.com/packages/micheh-teamcity-clover)
```

###  Alternatives

[nette/tester

Nette Tester: enjoyable unit testing in PHP with code coverage reporter. 🍏🍏🍎🍏

4917.3M1.5k](/packages/nette-tester)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[leanphp/behat-code-coverage

Generate Code Coverage reports for Behat tests

50359.8k2](/packages/leanphp-behat-code-coverage)[rregeer/phpunit-coverage-check

Check the code coverage using the clover report of phpunit

606.1M179](/packages/rregeer-phpunit-coverage-check)[nimut/phpunit-merger

Merge multiple PHPUnit reports into one file

501.7M7](/packages/nimut-phpunit-merger)[friends-of-phpspec/phpspec-code-coverage

Generate Code Coverage reports for PhpSpec tests

202.6M125](/packages/friends-of-phpspec-phpspec-code-coverage)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
