| 1 | #!perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | pherkin - Execute tests written using Test::BDD::Cucumber | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 VERSION | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | version 0.87 | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | pherkin | ||||||||||||||||||||||||||||
| 14 | pherkin some/path/features/ | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | C<pherkin> accepts a single argument of a directory name, defaulting to | ||||||||||||||||||||||||||||
| 19 | C<./features/> if none is specified. This directory is searched for feature | ||||||||||||||||||||||||||||
| 20 | files (any file matching C<*.feature>) and step definition files (any file | ||||||||||||||||||||||||||||
| 21 | matching C<*_steps.pl>). The step definitions are loaded, and then the features | ||||||||||||||||||||||||||||
| 22 | executed. | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Steps that pass are printed in green, those that fail in red, and those for | ||||||||||||||||||||||||||||
| 25 | which there is no step definition - or that are skipped as the result of a | ||||||||||||||||||||||||||||
| 26 | previous failure - as yellow. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | C<pherkin> will exit with a non-zero status if (and only if) the overall result | ||||||||||||||||||||||||||||
| 29 | is considered to be failing. | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head1 OPTIONS | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | Controlling @INC | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | -l, --lib Add 'lib' to @INC | ||||||||||||||||||||||||||||
| 36 | -b, --blib Add 'blib/lib' and 'blib/arch' to @INC | ||||||||||||||||||||||||||||
| 37 | -I [dir] Add given directory to @INC | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | Controlling Execution | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | -m, --match Only match steps in from features with available ones | ||||||||||||||||||||||||||||
| 42 | --matching [mode] Step function multiple matches behaviour: | ||||||||||||||||||||||||||||
| 43 | `first` (default) selects first match, `relaxed` warns | ||||||||||||||||||||||||||||
| 44 | and runs first match or `strict` stops execution | ||||||||||||||||||||||||||||
| 45 | --strict Requires steps to be defined; fails on undefined | ||||||||||||||||||||||||||||
| 46 | and pending steps (steps forcing 'skip') | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Output formatting | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | -o, --output Output harness. Defaults to 'TermColor'. See 'Outputs' | ||||||||||||||||||||||||||||
| 51 | -c, --theme Theme for 'TermColor'. `light` or `dark` (default) | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | Extra Steps | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | -s, --steps [path] Include an extra step file, or directory of step files | ||||||||||||||||||||||||||||
| 56 | (as identified by *_steps.pl; multiple use accepted) | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | Tag specifications | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | -t, --tags <expr> Run scenarios for which the tags satisfy the | ||||||||||||||||||||||||||||
| 61 | cucumber tag expression <expr> | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Configuration profiles (see CONFIGURATION PROFILES below/`man pherkin`) | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | -g, --config [path] A YAML file containing configuration profiles | ||||||||||||||||||||||||||||
| 66 | -p, --profile [name] Name of the profile to load from the above config file. | ||||||||||||||||||||||||||||
| 67 | Defaults to `default` | ||||||||||||||||||||||||||||
| 68 | --debug-profile Shows information about which profile was loaded and how | ||||||||||||||||||||||||||||
| 69 | and then terminates | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | Extensions | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | -e Extension::Module Load an extension. You can place a string in brackets at | ||||||||||||||||||||||||||||
| 74 | the end of the module name which will be eval'd and | ||||||||||||||||||||||||||||
| 75 | passed to new() for the extension. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | Help | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | --version Print the version number. | ||||||||||||||||||||||||||||
| 80 | -h, -?, --help Print usage information. | ||||||||||||||||||||||||||||
| 81 | --i18n LANG List keywords for a particular language. | ||||||||||||||||||||||||||||
| 82 | '--i18n help' lists all languages available. | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head1 OUTPUTS | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | C<pherkin> can output using any of the C<Test::BDD::Cucumber::Harness> output | ||||||||||||||||||||||||||||
| 87 | modules. L<TermColor> is the default, but L<TAP> is also a reasonable option: | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | pherkin -o TermColor some/path/feature # The default | ||||||||||||||||||||||||||||
| 90 | pherkin -o TAP some/path/feature # TAP text output (for e.g. prove) | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head1 CONFIGURATION PROFILES | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | You can specify sets of command line options using a YAML configuration file | ||||||||||||||||||||||||||||
| 95 | with named profiles in it, and the C<-g, --config> and C<-p, --profile> command | ||||||||||||||||||||||||||||
| 96 | line options. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | If you don't specify a config file, the following paths are searched (in order) | ||||||||||||||||||||||||||||
| 99 | for one: | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | (contents of $ENV{'PHERKIN_CONFIG'}) | ||||||||||||||||||||||||||||
| 102 | .pherkin.yaml | ||||||||||||||||||||||||||||
| 103 | ./config/pherkin.yaml | ||||||||||||||||||||||||||||
| 104 | ./.config/pherkin.yaml | ||||||||||||||||||||||||||||
| 105 | t/.pherkin.yaml | ||||||||||||||||||||||||||||
| 106 | ~/.pherkin.yaml | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | The contents of each profile is merged in as if you'd specified it on the | ||||||||||||||||||||||||||||
| 109 | command line. C<default> is used if you didn't specify one. For example: | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | default: | ||||||||||||||||||||||||||||
| 112 | steps: | ||||||||||||||||||||||||||||
| 113 | - foo/steps | ||||||||||||||||||||||||||||
| 114 | - ~/steps | ||||||||||||||||||||||||||||
| 115 | output: TermColor | ||||||||||||||||||||||||||||
| 116 | tags: @tag1 or @tag2 | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | is equivalent to: | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | --steps foo/steps --steps ~/steps --output TermColor --tags '@tag1 or @tag2' | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | If you specify both command-line options, and options in a configuration file, | ||||||||||||||||||||||||||||
| 123 | then the command-line ones override single-value items, and are placed at the | ||||||||||||||||||||||||||||
| 124 | end of multi-item ones. | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | If you specify C<--debug-profile> then information showing which profile is | ||||||||||||||||||||||||||||
| 127 | loaded and how is printed to STDOUT, and then `pherkin` terminates. | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =head2 EXTENSION CONFIGURATION | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | Extensions named in the C<extensions> section of the configuration will | ||||||||||||||||||||||||||||
| 132 | be loaded with the configuration from the configuration file: | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | default: | ||||||||||||||||||||||||||||
| 135 | includes: | ||||||||||||||||||||||||||||
| 136 | # include location where extensions reside on disk | ||||||||||||||||||||||||||||
| 137 | - t/lib | ||||||||||||||||||||||||||||
| 138 | extensions: | ||||||||||||||||||||||||||||
| 139 | # extension with configuration | ||||||||||||||||||||||||||||
| 140 | Test::CucumberPush: | ||||||||||||||||||||||||||||
| 141 | key1: value1 | ||||||||||||||||||||||||||||
| 142 | key2: value2 | ||||||||||||||||||||||||||||
| 143 | # extension without configuration | ||||||||||||||||||||||||||||
| 144 | Test::CucumberPop: | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | Notice that contrary to all other configuration parameters, the names | ||||||||||||||||||||||||||||
| 147 | of the extensions are not prefixed with a dash (i.e. '- t/lib' vs | ||||||||||||||||||||||||||||
| 148 | 'Test::CucumberPush'). | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | The example above is the equivalent of | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | use Test::CucumberPush; | ||||||||||||||||||||||||||||
| 153 | use Test::CucumberPop; | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | Test::CucumberPush->new({ 'key1' => 'value1', 'key2' => 'value2' }); | ||||||||||||||||||||||||||||
| 156 | Test::CucumberPop->new(); | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | Peter Sergeant C<pete@clueball.com> | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | Copyright 2012-2014, Peter Sergeant; Licensed under the same terms as Perl | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =cut | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # See App::pherkin for documentation | ||||||||||||||||||||||||||||
| 170 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 171 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 172 | 9 | ▶ | use App::pherkin; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 9 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||
| 175 | 9 | ▶ | if ( not -t STDOUT and not defined $ENV{'ANSI_COLORS_DISABLED'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-t STDOUT || defined $ENV{'ANSI_COLORS_DISABLED'}
MC/DC0%0/2
-t STDOUT || defined $ENV{'ANSI_COLORS_DISABLED'}
-t STDOUT
defined $ENV{'ANSI_COLORS_DISABLED'}
Truth table33%1/3
A || B
A= -t STDOUTB= defined $ENV{'ANSI_COLORS_DISABLED'}
| |||||||||||||||||||||||||||||
| 176 | 9 | $ENV{'ANSI_COLORS_DISABLED'} = 1; | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 9 | exit App::pherkin->new()->run(@ARGV); | |||||||||||||||||||||||||||