PHPackages                             elkan/behatformatter - 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. elkan/behatformatter

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

elkan/behatformatter
====================

This will create a formatter for Behat 3! Fast, Easy and Pretty!

V1.2.0(9y ago)1739.8k↓50%17[5 issues](https://github.com/ElkanRoelen/behatformatter/issues)[7 PRs](https://github.com/ElkanRoelen/behatformatter/pulls)MITPHPPHP &gt;=5.3.0

Since Feb 24Pushed 3y ago2 watchersCompare

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

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

BehatFormatter
--------------

[](#behatformatter)

Behat 3 extension for generating AWESOME reports from your test results.

[![Latest Stable Version](https://camo.githubusercontent.com/ac7a55c09e35ed3c943bde5e739ddaed83677b938d416665d1e95e2c3d3fd650/68747470733a2f2f706f7365722e707567782e6f72672f656c6b616e2f6265686174666f726d61747465722f762f737461626c65)](https://packagist.org/packages/elkan/behatformatter) [![Total Downloads](https://camo.githubusercontent.com/3730784c91027f2853b4f6022adfd46eb31e6a836c1e7cd9650421e9cff725cb/68747470733a2f2f706f7365722e707567782e6f72672f656c6b616e2f6265686174666f726d61747465722f646f776e6c6f616473)](https://packagist.org/packages/elkan/behatformatter) [![Latest Unstable Version](https://camo.githubusercontent.com/f694458b7cffa12a87388f04ebf3523d48113e78b31cf602ceaf03f62affc082/68747470733a2f2f706f7365722e707567782e6f72672f656c6b616e2f6265686174666f726d61747465722f762f756e737461626c65)](https://packagist.org/packages/elkan/behatformatter) [![License](https://camo.githubusercontent.com/f36b8da246318b161bf7e4ccf50049b71de7302f46686be08755f82cef0a8c86/68747470733a2f2f706f7365722e707567782e6f72672f656c6b616e2f6265686174666f726d61747465722f6c6963656e7365)](https://packagist.org/packages/elkan/behatformatter)

### Twig report

[](#twig-report)

Live demo available at:  (daily generated)

[![Twig Screenshot](https://camo.githubusercontent.com/e64237f1101c2344a7572827e0d08c1941c6c448da8c727819938f7cb1df8cd2/687474703a2f2f692e696d6775722e636f6d2f536c4a756871332e706e67)](https://camo.githubusercontent.com/e64237f1101c2344a7572827e0d08c1941c6c448da8c727819938f7cb1df8cd2/687474703a2f2f692e696d6775722e636f6d2f536c4a756871332e706e67)

Features
--------

[](#features)

- Create screenshot on failed steps.
- Create screenshot on result steps (Then).
- Save source code in html on failed steps (easy debugging).
- Possibility to set project title, description and logo in the testreport.
- Print report button
- Filter on successful or failed scenario's

It's easy!!
-----------

[](#its-easy)

- This tool can be installed easily with composer.
- Defining the formatter in the `behat.yml` file
- Modifying the settings in the `behat.yml` file
- Optional: Update `FeatureContext.php` to generate screenshots.

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

[](#installation)

### Prerequisites

[](#prerequisites)

This extension requires:

- PHP 5.3.x or higher
- Behat 3.x or higher

### Through composer

[](#through-composer)

The easiest way to keep your suite updated is to use [Composer](http://getcomposer.org%3E):

#### Install with composer:

[](#install-with-composer)

```
$ composer require --dev elkan/behatformatter
```

#### Install using `composer.json`

[](#install-using-composerjson)

Add BehatFormatter to the list of dependencies inside your `composer.json`.

```
{
    "require": {
        "behat/behat": "3.*@stable",
        "elkan/behatformatter": "v1.0.*",
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}
```

Then simply install it with composer:

```
$ composer install --dev --prefer-dist
```

You can read more about Composer on its [official webpage](http://getcomposer.org).

Basic usage
-----------

[](#basic-usage)

Activate the extension by specifying its class in your `behat.yml`:

```
# behat.yml
default:
  suites:
    ... # All your awesome suites come here

  formatters:
    html:
      output_path: %paths.base%/build/

  extensions:
    elkan\BehatFormatter\BehatFormatterExtension:
      projectName: BehatTest
      name: html
      renderer: Twig,Behat2
      file_name: Index
      print_args: true
      print_outp: true
      loop_break: true
      show_tags: true
```

Configuration
-------------

[](#configuration)

- `output_path` - The location where Behat will save the HTML reports. The path defined here is relative to `%paths.base%` and, when omitted, will be default set to the same path.
- `renderer` - The engine that Behat will use for rendering, thus the types of report format Behat should output (multiple report formats are allowed, separate them by commas). Allowed values are:
- *Behat2* for generating HTML reports like they were generated in Behat 2.
- *Twig* A new and more modern format based on Twig.
- *Minimal* An ultra minimal HTML output.
- `file_name` - (Optional) Behat will use a fixed filename and overwrite the same file after each build. By default, Behat will create a new HTML file using a random name (*"renderer name"*\_*"date hour"*).
- `projectName` - (Optional) Give your report a page titel.
- `projectDescription` - (Optional) Include a project description on your testreport.
- `projectImage` - (Optional) Include a project image in your testreport.
- `print_args` - (Optional) If set to `true`, Behat will add all arguments for each step to the report. (E.g. Tables).
- `print_outp` - (Optional) If set to `true`, Behat will add the output of each step to the report. (E.g. Exceptions).
- `loop_break` - (Optional) If set to `true`, Behat will add a separating break line after each execution when printing Scenario Outlines.
- `show_tags` - (Optional) If set to `true`, Behat will add tags when printing Scenario's and features.

Screenshots
-----------

[](#screenshots)

To generate screenshots in your testreport you have to change your `FeatureContext.php`:

#### From:

[](#from)

```
# FeatureContext.php
class FeatureContext extends MinkContext
{
...
}
```

#### To:

[](#to)

```
# FeatureContext.php
class FeatureContext extends elkan\BehatFormatter\Context\BehatFormatterContext
{
...
}
```

Extra function: Placeholders
----------------------------

[](#extra-function-placeholders)

It is possible to use placeholders in feature steps. Add a BeforeStep, BeforeScenario or BeforeSuite action to your context file containing a setTransformValues() action. You can add custom placeholders by using an array.

#### example context rules:

[](#example-context-rules)

```
    /**
     * @BeforeScenario
     */
    public function createTransformValues(){
        $this->setTransformValues(array(
            "" => "A simple test value",
            "" => time()
        ));
    }
```

#### Example feature:

[](#example-feature)

```
  @test
  Scenario: Sign up for the newsletter
    When I fill in "email" with "test++behat@bug-hunter.nl"
    And I press "Sign up"
```

#### Example Output:

[](#example-output)

```
  @test
  Scenario: Sign up for the newsletter
    When I fill in "email" with "test+1461777849+behat@bug-hunter.nl"
    And I press "Sign up"
```

Todo:
-----

[](#todo)

- save html on failures
- save REST responses in testreport
- JSON output - if wanted?
- colors in print stylesheet
- custom footer image/text

License and Authors
-------------------

[](#license-and-authors)

Authors:

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 83.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 ~88 days

Total

4

Last Release

3468d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12937350?v=4)[Elkan Roelen](/maintainers/ElkanRoelen)[@elkanroelen](https://github.com/elkanroelen)

---

Top Contributors

[![elkanroelen](https://avatars.githubusercontent.com/u/12937350?v=4)](https://github.com/elkanroelen "elkanroelen (5 commits)")[![codycraven](https://avatars.githubusercontent.com/u/1533965?v=4)](https://github.com/codycraven "codycraven (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elkan-behatformatter/health.svg)

```
[![Health](https://phpackages.com/badges/elkan-behatformatter/health.svg)](https://phpackages.com/packages/elkan-behatformatter)
```

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

22215.1M147](/packages/drupal-drupal-extension)[drevops/behat-steps

Collection of steps for Behat

25381.7k3](/packages/drevops-behat-steps)[devinci/devinci-behat-extension

Provides extra behat goodies.

17593.9k](/packages/devinci-devinci-behat-extension)[guikingone/panther-extension

Panther extension for Mink

232.0k](/packages/guikingone-panther-extension)

PHPackages © 2026

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