behat/debug-extension

Debug Behat scenarios and print any information to command line

Installs: 104 952

Dependents: 2

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

Type:behat-extension

1.0 2016-05-09 13:28 UTC

This package is auto-updated.

Last update: 2024-12-10 21:47:04 UTC


README

Print any information you'd like to a command line during the test suite execution.

Build Status Coverage Status Quality Score Total Downloads Latest Stable Version License

Usage

Add @debug tag to your feature definition:

@debug
Feature: Test

  Scenario: Test
  # ...

Add extension to your configuration file:

default:
  extensions:
    Behat\DebugExtension: ~

Extend your object with a trait:

use Behat\DebugExtension\Debugger;

class Example
{
    use Debugger;
}

Use the debug method wherever you like:

public function method()
{
    // ...
    self::debug([
        'Function arguments: %s',
        'Second line',
    ], [
        var_export(func_get_args(), true),
    ]);
    // ...
}

As you can see the debug method processed by sprintf() function, so second argument for a method is an array of placeholders.

Messages

Also, with this extension, you able to print styled messages to a command line.

new \Behat\DebugExtension\Message('comment', 2, [
    'This is a first line of a message that will be printed to a command line.',
    'Read documentation for this class to know how to use it.',
]);

Programmatic usage

export BEHAT_DEBUG=true

This environment variable tells that messages should be printed in any way.