---
name: "Test::BDD::Cucumber::Extension"
section: "3pm"
platform: "linux"
package: "libtest-bdd-cucumber-perl"
version: "0.87-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Test::BDD::Cucumber::Extension"
---

# Test::BDD::Cucumber::Extension(3pm)

Abstract superclass for extensions

## NAME

Test::BDD::Cucumber::Extension - Abstract superclass for extensions

## VERSION

version 0.87

## DESCRIPTION

Provides an abstract superclass for extensions.  Loaded extensions will have their hook-implementations triggered at specific points during the BDD script execution.

## PROPERTIES

### config

A hash, the configuration read from the config file, verbatim.  Extensions should look for their own configuration in\
   `$self`-\>config-\>{extensions}-\>{\<extension\>}

## METHODS

### steps\_directories()

The returns an arrayref whose values enumerate directories (relative to the directory of the extension) which hold step files to be loaded when the extension is loaded.

### pre\_execute($app)

Invoked by `"App::pherkin"` before executing any features.  This callback allows generic extension setup. Reports errors by calling **croak()**. It is called once per `"App::pherkin"` instance.

Note that the `"TAP::Parser::SourceHandler::Feature"` plugin for `"prove"` might instantiate multiple `"App::pherkin"` objects, meaning it will create multiple instances of the extensions too. As such, this callback may be called once per instance, but multiple times in a Perl image.

The source handler `"fork"`s the running Perl instance in order to support the parallel testing `"-j"` option. This callback will be called pre-fork.

### post\_execute()

Invoked by `"App::pherkin"` after executing all features.  This callback allows generic extension teardown and cleanup. Reports errors by calling **croak()**.

Note: When the `"TAP::Parser::SourceHandler::Feature"` plugin for `"prove"`\
  is used, there are no guarantees at this point that this hook is called\
  only once.

### pre\_feature($feature, $feature\_stash)

Invoked by the Executor before executing the background and feature scenarios and their respective pre-hooks. Reports errors by calling **croak()**.

### post\_feature($feature, $feature\_stash)

Invoked by the Executor after executing the background and feature scenarios and their respective post-hooks. Reports errors by calling **croak()**.

### pre\_scenario($scenario, $feature\_stash, $scenario\_stash)

Invoked by the Executor before executing the steps in `$scenario` and their respective pre-hooks. Reports errors by calling **croak()**.

### post\_scenario($scenario, $feature\_stash, $scenario\_stash, $failed)

Invoked by the Executor after executing all the steps in `$scenario` and their respective post-hooks. Reports errors by calling **croak()**.

`$failure` indicates whether any of the steps in the scenario has failed.

### pre\_step($stepdef, $step\_context)

Invoked by the Executor before executing each step in `$scenario`. Reports errors by calling **croak()**.

`$stepdef` contains a reference to an array with step data:

```
  [ qr//, { meta => $data }, $code ]
```

Feature and scenario stashes can be reached through

```
  $step_context->stash->{feature}
  # and
  $step_context->stash->{scenario}
```

Feature, scenario and step (from the feature file) are available as

```
  $step_context->feature
  $step_context->scenario
  $step_context->step
```

Note: **executed** steps, so not called for skipped steps.

### post\_step($stepdef, $step\_context, $failed, $result)

Invoked by the Executor after each executed step in `$scenario`. Reports errors by calling **croak()**.

`$failed` indicates that the step has not been completed successfully; this means the step can have failed, be marked as TODO or pending (not implemented).

`$result` is a `"Test::BDD::Cucumber::Model::Result"` instance which holds the completion status of the step.

Note: **executed** steps, so not called for skipped steps.

## AUTHOR

Erik Huelsmann `"ehuels@gmail.com"`

## LICENSE

```
  Copyright 2016-2023, Erik Huelsmann; Licensed under the same terms as Perl
```
