Coder Social home page Coder Social logo

behat-code-coverage's Introduction

behat-code-coverage

License Latest Stable Version Total Downloads Travis AppVeyor Pre Release

behat-code-coverage is a Behat extension that generates Code Coverage reports for Behat tests.

Generating Code Coverage reports allows you to to analyze which parts of your codebase are tested and how well. However, Code Coverage alone should NOT be used as a single metric defining how good your tests are.

Note! This is a maintained fork of vipsoft/code-coverage-extension, including codebase for vipsoft/code-coverage-common package with compatible version numbers for stable releases.

Requirements

Change Log

Please see CHANGELOG.md for information on recent changes.

Install

Install this package as a development dependency in your project:

$ composer require --dev leanphp/behat-code-coverage

Enable extension by editing behat.yml of your project:

default:
  extensions:
    LeanPHP\Behat\CodeCoverage\Extension:
      auth:       ~
      drivers:
        - local
      filter:     ~
      report:
        format:   html
        options:
          target: build/behat-coverage

This will sufficient to enable Code Coverage generation in html format in build/behat-coverage directory. This extension supports various [configuration options](#Configuration Options). For a fully annotated example configuration file check Configuration section.

Usage

If you execute bin/behat command, you will see code coverage generated in target (i.e. build/behat-coverage) directory (in html format):

$ bin/behat

Running with phpdbg

This extension now supports phpdbg, which results in faster execution when using more recent versions of PHP. Run phpspec via phpdbg:

$ phpdbg -qrr bin/behat run

Configuration

You can see fully annotated behat.yml example file below, which can be used as a starting point to further customize the defaults of the extension. The configuration file below has all of the [Configuration Options](#Configuration Options).

# behat.yml
# ...
default:
  extensions:
    LeanPHP\Behat\CodeCoverage\Extension:
      # http auth (optional)
      auth:        ~
      # select which driver to use when gatherig coverage data
      drivers:
        - local     # local Xdebug driver
      # filter options
      filter:
        forceCoversAnnotation:                false
        mapTestClassNameToCoveredClassName:   false
        whitelist:
          addUncoveredFilesFromWhitelist:     true
          processUncoveredFilesFromWhitelist: false
          include:
            directories:
              'src':
                prefix: 'src'
              'tests':
                prefix: 'src'
        blacklist:
          include:
            directories:
              'vendor':
                prefix: 'vendor'
      # report configuration
      report:
        # report format (html, clover, php, text)
        format:    html
        # report options
        options:
          target:: build/behat-coverage/html

Configuration Options

  • auth - HTTP authentication options (optional).
  • create (method / path) - TBA.
  • read (method / path) - TBA.
  • delete (method / path) - TBA.
  • drivers - a list of drivers for gathering code coverage data:
    • remote - remote Xdebug driver.
    • local - local Xdebug driver.
  • filter - various filter options:
    • forceCoversAnnotation - TBA
    • mapTestClassNameToCoveredClassName - TBA
    • whiltelist - whitelist specific options:
      • addUncoveredFilesFromWhiltelist - TBA
      • processUncoveredFilesFromWhitelist - TBA
      • include - a list of files or directories to include in whitelist:
        • directories - key containing whitelisted directories to include.
        • files - key containing whitelisted files to include.
      • exclude - a list of files or directories to exclude from whitelist:
        • directories - key containing whitelisted directories to exclude.
        • files - key containing whitelisted files to exclude.
  • report - reporter options:
    • format - specify report format (html, clover, php, text)
    • options - format options:
      • target - target/output directory

Authors

Copyright (c) 2017 ek9 [email protected] (https://ek9.co).

Copyright (c) 2013-2016 Anthon Pang, Konstantin Kudryashov everzet and various contributors for portions of code from vipsoft/code-coverage-extension and vipsoft/code-coverage-common projects.

License

Licensed under BSD-2-Clause License.

behat-code-coverage's People

Contributors

chartinger avatar ek9 avatar grob42 avatar robocoder avatar stof avatar thewilkybarkid avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.