1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#! perl
use Test::More;
use Capture::Tiny qw( capture );
use Test::Lib;
use MyTest::Class::Basic;
subtest 'command' => sub {
subtest "default options" => sub {
local @ARGV = ();
my ( $stdout, $stderr, @result ) =
capture { MyTest::Class::Basic->new_with_options->run };
is ( $stdout, "Hello world!\n", "message sent to stdout" );
is ( $stderr, '', "empty stderr" );
};
subtest "command line options" => sub {
local @ARGV = ( '--message', 'Hello Cleveland!' );
my ( $stdout, $stderr, @result ) =
capture { MyTest::Class::Basic->new_with_options->run };
is ( $stdout, "Hello Cleveland!\n", "message sent to stdout" );
is ( $stderr, '', "empty stderr" );
};
};
subtest 'subcommand' => sub {
subtest "default options" => sub {
local @ARGV = qw ( yell );
my ( $stdout, $stderr, @result ) =
capture { MyTest::Class::Basic->new_with_options->run };
is ( $stdout, "HELLO WORLD!\n", "message sent to stdout" );
is ( $stderr, '', "empty stderr" );
};
subtest "hyphenated options" => sub {
local @ARGV = qw ( yell --excitement-level 2 );
my ( $stdout, $stderr, @result ) =
capture { MyTest::Class::Basic->new_with_options->run };
is ( $stdout, "HELLO WORLD!!!\n", "message sent to stdout" );
is ( $stderr, '', "empty stderr" );
};
subtest "inline" => sub {
local @ARGV = qw ( whisper );
my ( $stdout, $stderr, @result ) =
capture { MyTest::Class::Basic->new_with_options->run };
is ( $stdout, "hello world!\n", "message sent to stdout" );
is ( $stderr, '', "empty stderr" );
};
};
done_testing;
|