2017 © Pedro Peláez
 

library php-test-reporter

PHP client for reporting test coverage to Code Climate

image

codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  • Wednesday, April 11, 2018
  • by mrb
  • Repository
  • 15 Watchers
  • 57 Stars
  • 996,171 Installations
  • PHP
  • 1818 Dependents
  • 2 Suggesters
  • 34 Forks
  • 2 Open issues
  • 14 Versions
  • 4 % Grown

The README.md

Build Status Code Climate Test Coverage, (*1)

codeclimate-test-reporter - [DEPRECATED]

These configuration instructions refer to a language-specific test reporter which is now deprecated in favor of our new unified test reporter client. The new test reporter is faster, distributed as a static binary, has support for parallelized CI builds, and will receive ongoing support by the team here. The existing test reporters for Ruby, Python, PHP, and Javascript are now deprecated., (*2)

Collects test coverage data from your PHP test suite and sends it to Code Climate's hosted, automated code review service., (*3)

Code Climate - https://codeclimate.com, (*4)

Important: If you encounter an error involving SSL certificates, see the Known Issue: SSL Certificate Error section below., (*5)

Important FYIs

Across the many different testing frameworks, setups, and environments, there are lots of variables at play. Before setting up test coverage, it's important to understand what we do and do not currently support:, (*6)

  • Single payload: We currently only support a single test coverage payload per commit. If you run your tests in multiple steps, or via parallel tests, Code Climate will only process the first payload that we receive. If you are using a CI, be sure to check if you are running your tests in a parallel mode., (*7)

    Note: There is one exception to this rule. We've specifically built an integration with Solano Labs to support parallel tests., (*8)

    Note: If you've configured Code Climate to analyze multiple languages in the same repository (e.g., Ruby and JavaScript), we can nonetheless only process test coverage information for one of these languages. We'll process the first payload that we receive., (*9)

  • Invalid File Paths: By default, our test reporters expect your application to exist at the root of your repository. If this is not the case, the file paths in your test coverage payload will not match the file paths that Code Climate expects.

Requirements

There are several requirements you'll need in order to use the PHP test reporter on your system:, (*10)

The test reporter uses the PHPUnit testing tool to generate code coverage information. These results show how much of your application's code is being executed by your unit tests. PHPUnit can't generate this information on its own though - it needs another tool, Xdebug. This is not included as a part of the PHPUnit (or PHP) install by default so you'll need to install it yourself., (*11)

Xdebug is installed as an extension to PHP, not a library. You can find more information about installing the tool via PECL on the project website., (*12)

If you execute your PHPUnit tests with the --coverage-clover option and receive the message "The Xdebug extension is not loaded. No code coverage will be generated." you will need to visit the Xdebug website and install the extension. If you do not, you'll most likely get an error something like this:, (*13)

PHP Warning:  simplexml_load_file(): I/O warning : failed to load external entity "[...]/build/logs/clover.xml" in [...]/vendor/satooshi/php-coveralls/src/Contrib/Bundle/CoverallsV1Bundle/Api/Jobs.php on line 52

Installation

This package requires a user, but not necessarily a paid account, on Code Climate, so if you don't have one the first step is to signup at: https://codeclimate.com., (*14)

Via composer

To install php-test-reporter with Composer run the following command., (*15)

$ composer require codeclimate/php-test-reporter --dev

This will get you the latest version of the reporter and install it. If you do want the master, untagged, version you may use the command below:, (*16)

$ composer require codeclimate/php-test-reporter:@dev --dev

As PHAR tool

Checkout the latest release here and replace X.X.X with the latest version., (*17)

$ RELEASE=X.X.X
$ wget -c "https://github.com/codeclimate/php-test-reporter/releases/download/$RELEASE/codeclimate-test-reporter.phar"

Usage

  • Generate coverage data to build/logs/clover.xml

Add the following to phpunit.xml.dist:, (*18)

<?xml version="1.0" encoding="UTF-8"?>
<phpunit ...>
  <logging>
    ...
    <log type="coverage-clover" target="build/logs/clover.xml"/>
    ...
  </logging>
</phpunit>

Or invoke phpunit as follows:, (*19)

$ phpunit --coverage-clover build/logs/clover.xml
  • Specifying your repo token as an environment variable, invoke the test-reporter:
$ CODECLIMATE_REPO_TOKEN="..." vendor/bin/test-reporter

# ... or via PHAR ...

$ CODECLIMATE_REPO_TOKEN="..." codeclimate-test-reporter.phar upload

The CODECLIMATE_REPO_TOKEN value is provided after you add your repo to your Code Climate account by clicking on "Setup Test Coverage" on the right hand side of your feed., (*20)

Please contact hello@codeclimate.com if you need any assistance setting this up., (*21)

Troubleshooting

If you're having trouble setting up or working with our test coverage feature, see our detailed help doc, which covers the most common issues encountered., (*22)

Known Issue: SSL Certificate Error

If you encounter an error involving SSL certificates when trying to report coverage data from your CI server, you can work around it by manually posting the data via curl:, (*23)

after_script:
  - CODECLIMATE_REPO_TOKEN="..." bin/test-reporter --stdout > codeclimate.json
  - "curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports"

Note: In the command above, you may need to change bin/test-reporter to vendor/bin/test-reporter, depending on your project's directory structure., (*24)

More details can be found in this issue., (*25)

Contributions

Patches, bug fixes, feature requests, and pull requests are welcome on the GitHub page for this project:, (*26)

https://github.com/codeclimate/php-test-reporter, (*27)

This package is maintained by Bryan Helmkamp (bryan@codeclimate.com)., (*28)

For more details, see CONTRIBUTING.md., (*29)

See LICENSE.txt, (*30)

Portions of the implementation were inspired by the php-coveralls project., (*31)

The Versions

11/04 2018
15/02 2017

v0.4.4

0.4.4.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

06/02 2017

v0.4.3

0.4.3.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

18/01 2017

v0.4.2

0.4.2.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

13/01 2017

dev-gd-token

dev-gd-token https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

11/01 2017

v0.4.1

0.4.1.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

29/12 2016

v0.4.0

0.4.0.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

18/05 2016

dev-abh-codeclimate

dev-abh-codeclimate https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

19/04 2016

v0.3.2

0.3.2.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

18/04 2016

v0.3.1

0.3.1.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

16/02 2016

v0.3.0

0.3.0.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

08/09 2015

v0.2.0

0.2.0.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

23/07 2014

v0.1.2

0.1.2.0 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate

21/07 2014

dev-fix_for_fatal_in_pr_13

dev-fix_for_fatal_in_pr_13 https://github.com/codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

  Sources   Download

MIT

The Requires

 

The Development Requires

coverage codeclimate