PHPackages                             eg9yigf4lgf4/behat-testomat-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. eg9yigf4lgf4/behat-testomat-formatter

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

eg9yigf4lgf4/behat-testomat-formatter
=====================================

This will create a testomat formatter for Behat.

v2.3.0(1y ago)015MITPHPPHP &gt;=5.3.0

Since May 27Pushed 1y agoCompare

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

READMEChangelogDependencies (5)Versions (13)Used By (0)

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

[](#behathtmlformatterplugin)

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

[![Latest Stable Version](https://camo.githubusercontent.com/b624f3d8b65df721b33d2d608107ea9d0d0dffd9c294d70e75148f2d2b8e053a/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f762f737461626c65)](https://packagist.org/packages/emuse/behat-html-formatter) [![Total Downloads](https://camo.githubusercontent.com/a2c14bf21b8ff4e9883967299db67599ae2134ae633ff1303a875c6bbea51d30/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f646f776e6c6f616473)](https://packagist.org/packages/emuse/behat-html-formatter) [![Latest Unstable Version](https://camo.githubusercontent.com/d60b72aa191247119e269033f6dffb1aac4e390da0dad8f8c40b6fb2eaaa600a/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f762f756e737461626c65)](https://packagist.org/packages/emuse/behat-html-formatter) [![License](https://camo.githubusercontent.com/4ccafe8fb0975cfdbda3d09c9596da813ad459067a4aa7cbbcbd0e8612675f49/68747470733a2f2f706f7365722e707567782e6f72672f656d7573652f62656861742d68746d6c2d666f726d61747465722f6c6963656e7365)](https://packagist.org/packages/emuse/behat-html-formatter)

### Twig report

[](#twig-report)

[![Twig Screenshot](https://camo.githubusercontent.com/0ef008d88774d969ed2f514f75e7879ee9e402699b7f4f81a741e0fe8cbe4ed3/687474703a2f2f692e696d6775722e636f6d2f6f307a437169422e706e67)](https://camo.githubusercontent.com/0ef008d88774d969ed2f514f75e7879ee9e402699b7f4f81a741e0fe8cbe4ed3/687474703a2f2f692e696d6775722e636f6d2f6f307a437169422e706e67)

### Behat 2 report

[](#behat-2-report)

[![Behat2 Screenshot](https://camo.githubusercontent.com/c5cc587370c2d3ecab4d808ab2d5e8a5e5c041db86ae48468d658088c94eb6fe/687474703a2f2f6935372e74696e797069632e636f6d2f323837673934322e6a7067)](https://camo.githubusercontent.com/c5cc587370c2d3ecab4d808ab2d5e8a5e5c041db86ae48468d658088c94eb6fe/687474703a2f2f6935372e74696e797069632e636f6d2f323837673934322e6a7067)

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 emuse/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",
        "emuse/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:
    default:
       contexts:
          - emuse\BehatHTMLFormatter\Context\ScreenshotContext:
               screenshotDir: build/html/behat/assets/screenshots
    ... # All your awesome suites come here
  formatters:
    html:
      output_path: %paths.base%/build/html/behat

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

### Command line options

[](#command-line-options)

Add the following to your behat command to print a report:

`behat --format html --out MYDIRECTORY`

Setting the format to html will output the various reports that you configure below (Behat2, Twig, Minimal, etc.)

You also need to specify the output directory for the reports as MYDIRECTORY.

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

[](#configuration)

### Formatter configuration

[](#formatter-configuration)

- `output_path` - The location where Behat will save the HTML reports. Use `%paths.base%` to build the full path.

### Extension configuration

[](#extension-configuration)

- `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"*).
- `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.

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 = preg_replace('/\W/', '', $scope->getFeature()->getTitle());

                              $scenarioName = $this->currentScenario->getTitle();
                              $fileName = preg_replace('/\W/', '', $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);
                // For Selenium2 Driver you can use:
                // file_put_contents('results/html/assets/screenshots/' . $featureFolder . '/' . $fileName, $this->getSession()->getDriver()->getScreenshot());
            }
        }
```

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/dutchiexl/BehatHtmlFormatterPlugin/issues/new).

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

[](#license-and-authors)

Authors:

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~345 days

Recently: every ~149 days

Total

11

Last Release

551d ago

Major Versions

v0.2.0 → 1.0.x-dev2021-07-14

v1.0.0 → v2.0.02023-03-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/00c808cd50fd36bdb3d0953113cf39ef8c7ae859986de2048b4dc8be9cfe31f7?d=identicon)[eG9yIGF4LGF4](/maintainers/eG9yIGF4LGF4)

---

Top Contributors

[![dutchiexl](https://avatars.githubusercontent.com/u/4411566?v=4)](https://github.com/dutchiexl "dutchiexl (55 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)")[![PurHur](https://avatars.githubusercontent.com/u/5864315?v=4)](https://github.com/PurHur "PurHur (7 commits)")[![kuczek](https://avatars.githubusercontent.com/u/2432505?v=4)](https://github.com/kuczek "kuczek (6 commits)")[![cckakhandki](https://avatars.githubusercontent.com/u/13152468?v=4)](https://github.com/cckakhandki "cckakhandki (5 commits)")[![rdotter](https://avatars.githubusercontent.com/u/4062360?v=4)](https://github.com/rdotter "rdotter (5 commits)")[![TESTPERSONAL](https://avatars.githubusercontent.com/u/6664588?v=4)](https://github.com/TESTPERSONAL "TESTPERSONAL (5 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)")[![Evgenas](https://avatars.githubusercontent.com/u/2884742?v=4)](https://github.com/Evgenas "Evgenas (2 commits)")[![throup](https://avatars.githubusercontent.com/u/1216362?v=4)](https://github.com/throup "throup (2 commits)")[![lopezs](https://avatars.githubusercontent.com/u/1067998?v=4)](https://github.com/lopezs "lopezs (1 commits)")[![pawel-grzona](https://avatars.githubusercontent.com/u/285337?v=4)](https://github.com/pawel-grzona "pawel-grzona (1 commits)")[![ptmkenny](https://avatars.githubusercontent.com/u/1451472?v=4)](https://github.com/ptmkenny "ptmkenny (1 commits)")[![rjb-dev](https://avatars.githubusercontent.com/u/16692687?v=4)](https://github.com/rjb-dev "rjb-dev (1 commits)")[![ajgarlag](https://avatars.githubusercontent.com/u/388184?v=4)](https://github.com/ajgarlag "ajgarlag (1 commits)")[![tikolakin](https://avatars.githubusercontent.com/u/5860505?v=4)](https://github.com/tikolakin "tikolakin (1 commits)")[![artberri](https://avatars.githubusercontent.com/u/454523?v=4)](https://github.com/artberri "artberri (1 commits)")[![Bersman](https://avatars.githubusercontent.com/u/1538239?v=4)](https://github.com/Bersman "Bersman (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eg9yigf4lgf4-behat-testomat-formatter/health.svg)

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

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[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)

PHPackages © 2026

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