2017 © Pedro Peláez
 

library cloak

Modern code coverage analysis library

image

cloak/cloak

Modern code coverage analysis library

  • Monday, March 28, 2016
  • by holyshared
  • Repository
  • 1 Watchers
  • 33 Stars
  • 5,379 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 6 Open issues
  • 42 Versions
  • 0 % Grown

The README.md

Cloak

Build Status Stories in Ready Scrutinizer Code Quality Coverage Status Dependency Status, (*1)

Cloak is a library that takes a code coverage.
This library works with PHP5.5 or more., (*2)

Requirements

  • xdebug >= 2.2.2

Installation

  1. Install the composer.
  2. Install the cloak., (*3)

    composer require cloak/cloak --dev

How to use

Setup for the report of code coverage

Setup is required to take a code coverage.
You can use the ConfigurationBuilder, and to apply the settings to the analyzer., (*4)

<?php

use cloak\CoverageAnalyzer;
use cloak\configuration\ConfigurationBuilder;

$builder = new ConfigurationBuilder();
$builder->includeFile('/example/src')
    ->excludeFile('/spec');

$analyzer = new CoverageAnalyzer( $builder->build() );

Take the code coverage

Run the start / stop at the place where want to take the code coverage.
After you can get the report, you need to run the getResult method., (*5)

$analyzer->start();

//I write code here want to take code coverage
example\example1();

$analyzer->stop();

$files = $analyzer->getResult()->getFiles();

foreach ($files as $file) {
    $result = sprintf("%s > %6.2f%% (%d/%d)",
        $file->getName(),
        $file->getCodeCoverage()->value(),
        $file->getExecutedLineCount(),
        $file->getExecutableLineCount()
    );
    echo $result . "\n";
}

Support multiple reporter

You can use at the same time more than one reporter.
Reporter that are supported by default are as follows., (*6)

  • TextReporter
  • ProcessingTimeReporter
  • LcovReporter
  • MarkdownReporter
  • TreeReporter

Usage is as follows., (*7)

$reporter = new CompositeReporter([
    new TextReporter(),
    new ProcessingTimeReporter()
]);

$builder = new ConfigurationBuilder();
$builder->includeFile('/example/src')
    ->excludeFile('/spec')
    ->reporter($reporter);

$analyzer = new CoverageAnalyzer( $builder->build() );

Result of the output

Code Coverage Started: 1 July 2014 at 12:00

100.00% (19/19) src/Analyzer.php
100.00% (27/27) src/Reporter/TextReporter.php
 85.71% ( 6/ 7) src/Reporter/Reportable.php
 81.25% (13/16) src/Configuration.php
 58.33% (14/24) src/ConfigurationBuilder.php

Code Coverage: 96.70%
Code Coverage Finished in 1.44294 seconds

Configuration file

If you use the configuration file, you can code simple., (*8)

use cloak\CoverageAnalyzer;
use cloak\configuration\ConfigurationLoader;

$loader = new ConfigurationLoader();
$configuration = $loader->loadConfiguration('cloak.toml');

$analyzer = new CoverageAnalyzer($configuration);
$analyzer->start();

$analyzer->stop();

Other documents

  1. Using the reporter

How to run the test

Run only unit test

composer test

Run the code coverage display and unit test

composer coverage

How to run the example

composer example

The Versions

23/09 2014

1.3.2.4

1.3.2.4

cloak is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

php simple code coverage text report

23/09 2014

1.3.2.3

1.3.2.3

cloak is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

php simple code coverage text report

23/09 2014
03/08 2014
27/07 2014

1.3.0

1.3.0.0

cloak is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

simple code coverage

20/07 2014

1.2.0

1.2.0.0

cloak is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

simple code coverage

19/07 2014

1.1.0

1.1.0.0

CodeAnalyzer is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

simple code coverage

30/03 2014

1.0.2

1.0.2.0

CodeAnalyzer is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

simple code coverage

30/03 2014

1.0.1

1.0.1.0

CodeAnalyzer is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

simple code coverage

16/03 2014

1.0.0

1.0.0.0

CodeAnalyzer is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared

simple code coverage

01/03 2014

1.0.0-alpha1

1.0.0.0-alpha1

CodeAnalyzer is a library that takes a code coverage.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar holyshared