| 1 | 22 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 22 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | package Test::BDD::Cucumber::Harness 0.87; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Test::BDD::Cucumber::Harness - Base class for creating harnesses | ||
| 9 | |||
| 10 | =head1 VERSION | ||
| 11 | |||
| 12 | version 0.87 | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | Harnesses allow your feature files to be executed while telling the outside | ||
| 17 | world about how the testing is going, and what's being tested. This is a base | ||
| 18 | class for creating new harnesses. You can see | ||
| 19 | L<Test::BDD::Cucumber::Harness::TermColor> and | ||
| 20 | L<Test::BDD::Cucumber::Harness::TAP> for examples, although if you need | ||
| 21 | to interact with the results in a more exciting way, you'd be best off | ||
| 22 | interacting with L<Test::BDD::Cucumber::Harness::Data>. | ||
| 23 | |||
| 24 | =head1 METHODS / EVENTS | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | 22 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 29 | 22 | ▶ | use Types::Standard qw( ArrayRef ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 30 | |||
| 31 | 53 | ▶ | has 'results' => ( is => 'ro', default => sub { [] }, isa => ArrayRef ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 32 | |||
| 33 | =head2 feature | ||
| 34 | |||
| 35 | =head2 feature_done | ||
| 36 | |||
| 37 | Called at the start and end of feature execution respectively. Both methods | ||
| 38 | accept a single argument of a L<Test::BDD::Cucumber::Model::Feature>. | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | 0 | ▶ | sub feature { my ( $self, $feature ) = @_; } |
|
Subroutine
feature: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 43 | 9 | ▶ | sub feature_done { my ( $self, $feature ) = @_; } |
|
Subroutine
feature_done: called CC=1 SCAR=0.0
Pod
documented
| |||
| 44 | |||
| 45 | =head2 background | ||
| 46 | |||
| 47 | =head2 background_done | ||
| 48 | |||
| 49 | If you have a background section, then we execute it as a quasi-scenario step | ||
| 50 | before each scenario. These hooks are fired before and after that, and passed | ||
| 51 | in the L<Test::BDD::Cucumber::Model::Scenario> that represents the Background | ||
| 52 | section, and a a dataset hash (although why would you use that?) | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | 66 | ▶ | sub background { my ( $self, $scenario, $dataset ) = @_; } |
|
Subroutine
background: called CC=1 SCAR=0.0
Pod
documented
| |||
| 57 | 66 | ▶ | sub background_done { my ( $self, $scenario, $dataset ) = @_; } |
|
Subroutine
background_done: called CC=1 SCAR=0.0
Pod
documented
| |||
| 58 | |||
| 59 | =head2 scenario | ||
| 60 | |||
| 61 | =head2 scenario_done | ||
| 62 | |||
| 63 | Called at the start and end of scenario execution respectively. Both methods | ||
| 64 | accept a L<Test::BDD::Cucumber::Model::Scenario> module and a dataset hash. | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | 0 | ▶ | sub scenario { my ( $self, $scenario, $dataset ) = @_; } |
|
Subroutine
scenario: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 69 | 0 | ▶ | sub scenario_done { my ( $self, $scenario, $dataset ) = @_; } |
|
Subroutine
scenario_done: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 70 | |||
| 71 | =head2 scenario_skip | ||
| 72 | |||
| 73 | Called instead of C<scenario> and C<scenario_done> when a scenario is skipped. | ||
| 74 | Although the only reason for skipping scenarios currently is being excluded | ||
| 75 | due to tag expressions, this may change in the future. | ||
| 76 | |||
| 77 | =cut | ||
| 78 | |||
| 79 | 64 | ▶ | sub scenario_skip { my ( $self, $scenario, $dataset ) = @_; } |
|
Subroutine
scenario_skip: called CC=1 SCAR=0.0
Pod
documented
| |||
| 80 | |||
| 81 | =head2 step | ||
| 82 | |||
| 83 | =head2 step_done | ||
| 84 | |||
| 85 | Called at the start and end of step execution respectively. Both methods | ||
| 86 | accept a L<Test::BDD::Cucumber::StepContext> object. C<step_done> also accepts | ||
| 87 | a L<Test::BDD::Cucumber::Model::Result> object and an arrayref of arrayrefs with | ||
| 88 | locations of consolidated matches, for highlighting. | ||
| 89 | |||
| 90 | [ [2,5], [7,9] ] | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | 0 | ▶ | sub step { my ( $self, $context ) = @_; } |
|
Subroutine
step: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 95 | 0 | ▶ | sub step_done { my ( $self, $context, $result ) = @_; } |
|
Subroutine
step_done: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 96 | |||
| 97 | =head2 sub_step | ||
| 98 | |||
| 99 | =head2 sub_step_done | ||
| 100 | |||
| 101 | As per C<step> and C<step_done>, but for steps that have been called from other | ||
| 102 | steps. None of the included harnesses respond to these methods, because | ||
| 103 | generally the whole thing should be transparent, and the parent step handles | ||
| 104 | passes, failures, etc. | ||
| 105 | |||
| 106 | =cut | ||
| 107 | |||
| 108 | 24 | ▶ | sub sub_step { my ( $self, $context ) = @_; } |
|
Subroutine
sub_step: called CC=1 SCAR=0.0
Pod
documented
| |||
| 109 | 24 | ▶ | sub sub_step_done { my ( $self, $context, $result ) = @_; } |
|
Subroutine
sub_step_done: called CC=1 SCAR=0.0
Pod
documented
| |||
| 110 | |||
| 111 | =head2 startup | ||
| 112 | |||
| 113 | =head2 shutdown | ||
| 114 | |||
| 115 | Some tests will run one feature, some will run many. For this reason, you may | ||
| 116 | have harnesses that have something they need to do on start (print an HTML | ||
| 117 | header), that they shouldn't do at the start of every feature, or a close-down | ||
| 118 | task (like running C<done_testing()>), that again shouldn't happen on I<every> | ||
| 119 | feature close-out, just the last. | ||
| 120 | |||
| 121 | Just C<$self> as the single argument for both. | ||
| 122 | |||
| 123 | =cut | ||
| 124 | |||
| 125 | 14 | ▶ | sub startup { my $self = shift; } |
|
Subroutine
startup: called CC=1 SCAR=0.0
Pod
documented
| |||
| 126 | 9 | ▶ | sub shutdown { my $self = shift; } |
|
Subroutine
shutdown: called CC=1 SCAR=0.0
Pod
documented
| |||
| 127 | |||
| 128 | =head2 add_result | ||
| 129 | |||
| 130 | Called before C<step_done> with the step's result. Expected to silently add the | ||
| 131 | result in to a pool that facilitate the C<result> method. No need to override | ||
| 132 | this behaviour. | ||
| 133 | |||
| 134 | =head2 result | ||
| 135 | |||
| 136 | Returns a collective view on the passing status of all steps run so far, | ||
| 137 | as a L<Test::BDD::Cucumber::Model::Result> object. Default implementation should | ||
| 138 | be fine for all your needs. | ||
| 139 | |||
| 140 | =cut | ||
| 141 | |||
| 142 | 987 | ▶ | sub add_result { |
|
Subroutine
add_result: called CC=1 SCAR=0.0
Pod
documented
| |||
| 143 | 987 | my $self = shift; | |
| 144 | 987 | push( @{ $self->results }, shift() ); | |
| 145 | } | ||
| 146 | |||
| 147 | 14 | ▶ | sub result { |
|
Subroutine
result: called CC=1 SCAR=0.0
Pod
documented
| |||
| 148 | 14 | my $self = shift; | |
| 149 | return Test::BDD::Cucumber::Model::Result->from_children( | ||
| 150 | 14 | @{ $self->results } ); | |
| 151 | } | ||
| 152 | |||
| 153 | =head1 AUTHOR | ||
| 154 | |||
| 155 | Peter Sergeant C<pete@clueball.com> | ||
| 156 | |||
| 157 | =head1 LICENSE | ||
| 158 | |||
| 159 | Copyright 2019-2023, Erik Huelsmann | ||
| 160 | Copyright 2011-2019, Peter Sergeant; Licensed under the same terms as Perl | ||
| 161 | |||
| 162 | =cut | ||
| 163 | |||
| 164 | 22 | 1; | |