« blib/lib/Test/BDD/Cucumber/Model/Document.pm
↑ Summary
examples/calculator/features/step_definitions/calculator_steps.pl »
| 1 | 3 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | package Test::BDD::Cucumber::Extension 0.87; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Test::BDD::Cucumber::Extension - Abstract superclass for extensions | ||
| 9 | |||
| 10 | =head1 VERSION | ||
| 11 | |||
| 12 | version 0.87 | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | Provides an abstract superclass for extensions. Loaded extensions will | ||
| 17 | have their hook-implementations triggered at specific points during | ||
| 18 | the BDD script execution. | ||
| 19 | |||
| 20 | =cut | ||
| 21 | |||
| 22 | 3 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 3 | ▶ | use Types::Standard qw( HashRef ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | =head1 PROPERTIES | ||
| 26 | |||
| 27 | |||
| 28 | =head2 config | ||
| 29 | |||
| 30 | A hash, the configuration read from the config file, verbatim. Extensions | ||
| 31 | should look for their own configuration in | ||
| 32 | $self->config->{extensions}->{<extension>} | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | 3 | has config => ( is => 'rw', isa => HashRef ); | |
| 37 | |||
| 38 | =head1 METHODS | ||
| 39 | |||
| 40 | =head2 steps_directories() | ||
| 41 | |||
| 42 | The returns an arrayref whose values enumerate directories (relative to | ||
| 43 | the directory of the extension) which hold step files to be loaded when | ||
| 44 | the extension is loaded. | ||
| 45 | |||
| 46 | =cut | ||
| 47 | |||
| 48 | 0 | ▶ | sub step_directories { return []; } |
|
Subroutine
step_directories: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 49 | |||
| 50 | =head2 pre_execute($app) | ||
| 51 | |||
| 52 | Invoked by C<App::pherkin> before executing any features. This callback | ||
| 53 | allows generic extension setup. Reports errors by calling croak(). It is | ||
| 54 | called once per C<App::pherkin> instance. | ||
| 55 | |||
| 56 | Note that the C<TAP::Parser::SourceHandler::Feature> plugin for C<prove> | ||
| 57 | might instantiate multiple C<App::pherkin> objects, meaning it will create | ||
| 58 | multiple instances of the extensions too. As such, this callback may be | ||
| 59 | called once per instance, but multiple times in a Perl image. | ||
| 60 | |||
| 61 | The source handler C<fork>s the running Perl instance in order to support | ||
| 62 | the parallel testing C<-j> option. This callback will be called pre-fork. | ||
| 63 | |||
| 64 | =head2 post_execute() | ||
| 65 | |||
| 66 | Invoked by C<App::pherkin> after executing all features. This callback | ||
| 67 | allows generic extension teardown and cleanup. Reports errors by calling | ||
| 68 | croak(). | ||
| 69 | |||
| 70 | Note: When the C<TAP::Parser::SourceHandler::Feature> plugin for C<prove> | ||
| 71 | is used, there are no guarantees at this point that this hook is called | ||
| 72 | only once. | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | 1 | ▶ | sub pre_execute { return; } |
|
Subroutine
pre_execute: called CC=1 SCAR=0.0
Pod
documented
| |||
| 77 | 1 | ▶ | sub post_execute { return; } |
|
Subroutine
post_execute: called CC=1 SCAR=0.0
Pod
documented
| |||
| 78 | |||
| 79 | =head2 pre_feature($feature, $feature_stash) | ||
| 80 | |||
| 81 | Invoked by the Executor before executing the background and feature scenarios | ||
| 82 | and their respective pre-hooks. Reports errors by calling croak(). | ||
| 83 | |||
| 84 | =head2 post_feature($feature, $feature_stash) | ||
| 85 | |||
| 86 | Invoked by the Executor after executing the background and feature scenarios | ||
| 87 | and their respective post-hooks. Reports errors by calling croak(). | ||
| 88 | |||
| 89 | =cut | ||
| 90 | |||
| 91 | 1 | ▶ | sub pre_feature { return; } |
|
Subroutine
pre_feature: called CC=1 SCAR=0.0
Pod
documented
| |||
| 92 | 1 | ▶ | sub post_feature { return; } |
|
Subroutine
post_feature: called CC=1 SCAR=0.0
Pod
documented
| |||
| 93 | |||
| 94 | =head2 pre_scenario($scenario, $feature_stash, $scenario_stash) | ||
| 95 | |||
| 96 | Invoked by the Executor before executing the steps in $scenario and | ||
| 97 | their respective pre-hooks. Reports errors by calling croak(). | ||
| 98 | |||
| 99 | =head2 post_scenario($scenario, $feature_stash, $scenario_stash, $failed) | ||
| 100 | |||
| 101 | Invoked by the Executor after executing all the steps in $scenario | ||
| 102 | and their respective post-hooks. Reports errors by calling croak(). | ||
| 103 | |||
| 104 | $failure indicates whether any of the steps in the scenario has failed. | ||
| 105 | |||
| 106 | =cut | ||
| 107 | |||
| 108 | 1 | ▶ | sub pre_scenario { return; } |
|
Subroutine
pre_scenario: called CC=1 SCAR=0.0
Pod
documented
| |||
| 109 | 1 | ▶ | sub post_scenario { return; } |
|
Subroutine
post_scenario: called CC=1 SCAR=0.0
Pod
documented
| |||
| 110 | |||
| 111 | =head2 pre_step($stepdef, $step_context) | ||
| 112 | |||
| 113 | Invoked by the Executor before executing each step in $scenario. | ||
| 114 | Reports errors by calling croak(). | ||
| 115 | |||
| 116 | C<$stepdef> contains a reference to an array with step data: | ||
| 117 | |||
| 118 | [ qr//, { meta => $data }, $code ] | ||
| 119 | |||
| 120 | Feature and scenario stashes can be reached through | ||
| 121 | |||
| 122 | $step_context->stash->{feature} | ||
| 123 | # and | ||
| 124 | $step_context->stash->{scenario} | ||
| 125 | |||
| 126 | Feature, scenario and step (from the feature file) are available as | ||
| 127 | |||
| 128 | $step_context->feature | ||
| 129 | $step_context->scenario | ||
| 130 | $step_context->step | ||
| 131 | |||
| 132 | Note: B<executed> steps, so not called for skipped steps. | ||
| 133 | |||
| 134 | =head2 post_step($stepdef, $step_context, $failed, $result) | ||
| 135 | |||
| 136 | Invoked by the Executor after each executed step in $scenario. | ||
| 137 | Reports errors by calling croak(). | ||
| 138 | |||
| 139 | $failed indicates that the step has not been completed successfully; | ||
| 140 | this means the step can have failed, be marked as TODO or pending | ||
| 141 | (not implemented). | ||
| 142 | |||
| 143 | $result is a C<Test::BDD::Cucumber::Model::Result> instance which | ||
| 144 | holds the completion status of the step. | ||
| 145 | |||
| 146 | Note: B<executed> steps, so not called for skipped steps. | ||
| 147 | |||
| 148 | =cut | ||
| 149 | |||
| 150 | 0 | ▶ | sub pre_step { return; } |
|
Subroutine
pre_step: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 151 | 3 | ▶ | sub post_step { return; } |
|
Subroutine
post_step: called CC=1 SCAR=0.0
Pod
documented
| |||
| 152 | |||
| 153 | =head1 AUTHOR | ||
| 154 | |||
| 155 | Erik Huelsmann C<ehuels@gmail.com> | ||
| 156 | |||
| 157 | =head1 LICENSE | ||
| 158 | |||
| 159 | Copyright 2016-2023, Erik Huelsmann; Licensed under the same terms as Perl | ||
| 160 | |||
| 161 | =cut | ||
| 162 | |||
| 163 | 3 | 1; | |