PHPackages                             roydude/behat-html-formatter - 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. roydude/behat-html-formatter

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

roydude/behat-html-formatter
============================

Creates an HTML report for Behat tests (enhanced version of emuse/behat-html-formatter)

v0.1.0(10y ago)115.7k↓33.3%2PHPPHP &gt;=5.3.0

Since May 27Pushed 9y ago1 watchersCompare

[ Source](https://github.com/roydude/BehatHtmlFormatterPlugin)[ Packagist](https://packagist.org/packages/roydude/behat-html-formatter)[ RSS](/packages/roydude-behat-html-formatter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

BehatHtmlFormatterPlugin
------------------------

[](#behathtmlformatterplugin)

Behat 3 extension for generating HTML reports from your test results (custom version of the original from emuse: ). The changes I have made only relate to the Twig report (see below).

[![Latest Stable Version](https://camo.githubusercontent.com/1e5fbca67ee9a7f8a761797066c239f14c2edcc23081ba8ed6706ca345bcf380/68747470733a2f2f706f7365722e707567782e6f72672f726f79647564652f62656861742d68746d6c2d666f726d61747465722f762f737461626c65)](https://packagist.org/packages/roydude/behat-html-formatter) [![Total Downloads](https://camo.githubusercontent.com/45b43046d1eea0432e65a16d824bda126e0a997ca8bad2f25e0137e33ab01712/68747470733a2f2f706f7365722e707567782e6f72672f726f79647564652f62656861742d68746d6c2d666f726d61747465722f646f776e6c6f616473)](https://packagist.org/packages/roydude/behat-html-formatter) [![Latest Unstable Version](https://camo.githubusercontent.com/ad5deb2927687374488828bea54071626f5c39db1caefc9c7c6d1febb52a50ba/68747470733a2f2f706f7365722e707567782e6f72672f726f79647564652f62656861742d68746d6c2d666f726d61747465722f762f756e737461626c65)](https://packagist.org/packages/roydude/behat-html-formatter) [![License](https://camo.githubusercontent.com/9e3eba697bdeabd09e12ac29eeabb998c51fd23b2c3d39aaaf6d99c71a8e928b/68747470733a2f2f706f7365722e707567782e6f72672f726f79647564652f62656861742d68746d6c2d666f726d61747465722f6c6963656e7365)](https://packagist.org/packages/roydude/behat-html-formatter)

### Twig report

[](#twig-report)

[![Twig Screenshot](https://camo.githubusercontent.com/048789d4029774b7474654df032c485abeea9d73c14d406a7e30a925884c05c8/687474703a2f2f692e696d6775722e636f6d2f79746e497650562e706e67)](https://camo.githubusercontent.com/048789d4029774b7474654df032c485abeea9d73c14d406a7e30a925884c05c8/687474703a2f2f692e696d6775722e636f6d2f79746e497650562e706e67)[![Twig Screenshot](https://camo.githubusercontent.com/100b0c70f1f04249196b022536e699b2f5a7c2dca16845fa5cca1c17cd5beff7/687474703a2f2f692e696d6775722e636f6d2f505364664c33592e706e67)](https://camo.githubusercontent.com/100b0c70f1f04249196b022536e699b2f5a7c2dca16845fa5cca1c17cd5beff7/687474703a2f2f692e696d6775722e636f6d2f505364664c33592e706e67)

How?
----

[](#how)

- The tool can be installed easily with composer.
- Defining the formatter in the `behat.yml` file
- Modifying the settings in the `behat.yml`file

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 roydude/behat-html-formatter
```

#### Install using `composer.json`

[](#install-using-composerjson)

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

```
{
    "require": {
        "behat/behat": "3.*@stable",
        "roydude/behat-html-formatter": "0.1.*",
    },
    "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/html/behat

  extensions:
    roydude\BehatHTMLFormatter\BehatHTMLFormatterExtension:
      name: html
      renderer: Twig
      file_name: index
      print_args: true
      print_outp: true
      loop_break: true
```

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

[](#configuration)

- Makeing `(noreport)` part of a test suit name will mean it's excuded from the report (handy for cache tests, for example, which aren't so interesting to business users who read the report).
- `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:
- *Twig* A new and modern report format based on Twig.
- `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"*).
- `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.

Blocked tests
-------------

[](#blocked-tests)

To mark a test as skipped make sure it exits with PendingExcpetion, i.e.:

```
throw new PendingException ("This scenario is blocked by bug MYPROJ-101");
```

Screenshot
----------

[](#screenshot)

The facility exists to embed a screenshot into test failures.

Currently png is the only supported image format.

In order to embed a screenshot, you will need to take a screenshot using your favourite webdriver and store it in the following filepath format:

results/html/assets/screenshots/{{feature\_name}}/{{scenario\_name}}.png

The feature\_name and scenario\_name variables will need to be the relevant item names without spaces.

Below is an example of FeatureContext methods which will produce an image file in the above format:

```
        /**
         * @BeforeScenario
         *
         * @param BeforeScenarioScope $scope
         *
         */
        public function setUpTestEnvironment($scope)
        {
            $this->currentScenario = $scope->getScenario();
        }

        /**
         * @AfterStep
         *
         * @param AfterStepScope $scope
         */
        public function afterStep($scope)
        {
            //if test has failed, and is not an api test, get screenshot
            if(!$scope->getTestResult()->isPassed())
            {
                //create filename string
                $featureFolder = str_replace(' ', '', $scope->getFeature()->getTitle());

                $scenarioName = $this->currentScenario->getTitle();
                $fileName = str_replace(' ', '', $scenarioName) . '.png';

                //create screenshots directory if it doesn't exist
                if (!file_exists('results/html/assets/screenshots/' . $featureFolder)) {
                    mkdir('results/html/assets/screenshots/' . $featureFolder);
                }

                //take screenshot and save as the previously defined filename
                $this->driver->takeScreenshot('results/html/assets/screenshots/' . $featureFolder . '/' . $fileName);
            }
        }
```

Note that the currentScenario variable will need to be at class level and generated in the @BeforeScenario method as Behat does not currently support obtaining the current Scenario in the @AfterStep method, where the screenshot is generated

Issue Submission
----------------

[](#issue-submission)

When you need additional support or you discover something *strange*, feel free to [Create a new issue](https://github.com/roydude/BehatHtmlFormatterPlugin/issues/new).

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

[](#license-and-authors)

Authors:

To do
-----

[](#to-do)

- Consider adding buttons for Skipped and Undefined.
- Simplify screenshots.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.2% 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

Unknown

Total

1

Last Release

4009d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35ca98bce3b6e335c855da173ad0b0d9ca5c6a2df65137991d01a19d77d4ac5b?d=identicon)[roydude](/maintainers/roydude)

---

Top Contributors

[![dutchiexl](https://avatars.githubusercontent.com/u/4411566?v=4)](https://github.com/dutchiexl "dutchiexl (44 commits)")[![lmrafael](https://avatars.githubusercontent.com/u/2047805?v=4)](https://github.com/lmrafael "lmrafael (16 commits)")[![kwisatz](https://avatars.githubusercontent.com/u/237949?v=4)](https://github.com/kwisatz "kwisatz (10 commits)")[![kuczek](https://avatars.githubusercontent.com/u/2432505?v=4)](https://github.com/kuczek "kuczek (6 commits)")[![throup](https://avatars.githubusercontent.com/u/1216362?v=4)](https://github.com/throup "throup (2 commits)")[![ich123](https://avatars.githubusercontent.com/u/419039?v=4)](https://github.com/ich123 "ich123 (2 commits)")[![legovaer](https://avatars.githubusercontent.com/u/5813212?v=4)](https://github.com/legovaer "legovaer (2 commits)")[![BramDriesen](https://avatars.githubusercontent.com/u/12573202?v=4)](https://github.com/BramDriesen "BramDriesen (1 commits)")[![estheban](https://avatars.githubusercontent.com/u/638460?v=4)](https://github.com/estheban "estheban (1 commits)")[![lopezs](https://avatars.githubusercontent.com/u/1067998?v=4)](https://github.com/lopezs "lopezs (1 commits)")[![Haehnchen](https://avatars.githubusercontent.com/u/1011712?v=4)](https://github.com/Haehnchen "Haehnchen (1 commits)")

### Embed Badge

![Health badge](/badges/roydude-behat-html-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/roydude-behat-html-formatter/health.svg)](https://phpackages.com/packages/roydude-behat-html-formatter)
```

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

22215.1M147](/packages/drupal-drupal-extension)[friends-of-behat/variadic-extension

Variadic support for behat context arguments

2286.0M446](/packages/friends-of-behat-variadic-extension)[wp-cli/wp-cli-tests

WP-CLI testing framework

422.7M87](/packages/wp-cli-wp-cli-tests)[drevops/behat-steps

Collection of steps for Behat

25381.7k3](/packages/drevops-behat-steps)[elkan/behatformatter

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

1739.8k](/packages/elkan-behatformatter)[friends-of-behat/test-context

Provides reusable context that helps in testing Behat extensions.

1722.0k12](/packages/friends-of-behat-test-context)

PHPackages © 2026

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