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

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

khalidumar/behatformatter
=========================

This will create a formatter for Behat 3! Fast, Easy and Pretty! &amp; Added support for php 7.2+

v1.3.5(7y ago)038MITPHPPHP &gt;=5.3.0

Since Feb 24Pushed 7y ago1 watchersCompare

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

READMEChangelog (6)Dependencies (7)Versions (12)Used By (0)

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

[](#behatformatter)

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

[![Latest Stable Version](https://camo.githubusercontent.com/d291dbe0f5ac1ee8e9a15713193102f74502a73ab29b587f307a1227727aa203/68747470733a2f2f706f7365722e707567782e6f72672f6b68616c6964756d61722f6265686174666f726d61747465722f76657273696f6e)](https://packagist.org/packages/khalidumar/behatformatter)[![Total Downloads](https://camo.githubusercontent.com/9597caf31787ed99868e0f4d262ab5b63352e9652f8b708e97a4a7ac1d033162/68747470733a2f2f706f7365722e707567782e6f72672f6b68616c6964756d61722f6265686174666f726d61747465722f646f776e6c6f616473)](https://packagist.org/packages/khalidumar/behatformatter)[![License](https://camo.githubusercontent.com/e5c80bc8ae263465fc4f1e55323d16eaf3a27781560e911473d96717555a3dad/68747470733a2f2f706f7365722e707567782e6f72672f6b68616c6964756d61722f6265686174666f726d61747465722f6c6963656e7365)](https://packagist.org/packages/khalidumar/behatformatter)[![Latest Unstable Version](https://camo.githubusercontent.com/5a9d8b8cd60594db280a175d609bbd89115d7652d9849414349f89fc078aae9f/68747470733a2f2f706f7365722e707567782e6f72672f6b68616c6964756d61722f6265686174666f726d61747465722f762f756e737461626c65)](//packagist.org/packages/khalidumar/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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 64.7% 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 ~91 days

Recently: every ~2 days

Total

11

Last Release

2816d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/76a2be75681338f6502736f6186b3000e3f514b609b8b6c924622d345b8dcc7f?d=identicon)[khalidumarr](/maintainers/khalidumarr)

---

Top Contributors

[![khalidumarr](https://avatars.githubusercontent.com/u/8342725?v=4)](https://github.com/khalidumarr "khalidumarr (11 commits)")[![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/khalidumar-behatformatter/health.svg)

```
[![Health](https://phpackages.com/badges/khalidumar-behatformatter/health.svg)](https://phpackages.com/packages/khalidumar-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)[elkan/behatformatter

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

1739.8k](/packages/elkan-behatformatter)[guikingone/panther-extension

Panther extension for Mink

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

PHPackages © 2026

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