148
Perl Testing

Perl Testing

Embed Size (px)

DESCRIPTION

german talk about the variety of CPAN testing modules

Citation preview

Page 1: Perl Testing

Perl Testing

Page 2: Perl Testing

Testphilosophie

Page 3: Perl Testing

Testgeschichte

bis 1956 - Debugging oriented1957–1978 - Demonstration oriented

1979–1982 - Destruction oriented1983–1987 - Evaluation oriented1988–2000 - Prevention oriented

Page 4: Perl Testing

Testwissenschaft

Smoke -Unit - Regression -white-/Grey-/Black– box

Page 5: Perl Testing

Testmafia

V-ModellXP

Page 6: Perl Testing

Testreligion

Page 7: Perl Testing

Am Anfang

Page 8: Perl Testing

Am Anfang

Page 9: Perl Testing

1987: Perl 1.0

starke Testsuite

Page 10: Perl Testing

1987: Perl 1.0

starke Testsuite

Anfänge von TAP

Page 11: Perl Testing

1987: Perl 1.0

starke Testsuite

Anfänge von TAP

Testscripte benutzten print

Page 12: Perl Testing

1987: Perl 1.0

starke Testsuite

Anfänge von TAP

Testscripte benutzten print

TEST fasste zusammen

Page 13: Perl Testing

1987: Perl 1.0

starke Testsuite

Anfänge von TAP

Testscripte benutzten print

TEST => Test::[Harness|Run]

Page 14: Perl Testing

Starte Tests

Page 15: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

Page 16: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.pl

Page 17: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

Page 18: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

prove # oberhalb von t

Page 19: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

prove # oberhalb von tprove -v # mehr Ausgabe

Page 20: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

prove # oberhalb von tprove --verbose # mehr Ausgabeprove t xt # + alternative Tests

Page 21: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

prove # oberhalb von tprove --verbose # mehr Ausgabeprove t xt # + alternative Testsprove -r # alle dir (keine subdir)

Page 22: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

prove # oberhalb von tprove --verbose # mehr Ausgabeprove t xt # + alternative Testsprove -r # alle dir (keine subdir)prove --jobs N # nutze N Kerne

Page 23: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

prove # oberhalb von tprove --verbose # mehr Ausgabeprove t xt # + alternative Testsprove -r # alle dir (keine subdir)prove --jobs N # nutze N Kerneprove -s # shuffle–zufällige Reih.

Page 24: Perl Testing

Starte Testsmake test # nur wenn Makefile da ist

perl t/datei.plperl datei.pl # BEGIN {chdir '..' if -d '../t'}

prove # oberhalb von tprove --verbose # mehr Ausgabeprove t xt # + alternative Testsprove -r # alle dir (keine subdir)prove --jobs N # nutze N Kerneprove -s # shuffle–zufällige Reih.

Page 25: Perl Testing

Test

Page 26: Perl Testing

Test use Test;

tests =>, todo=>, onfail =>

ok(); skip(); plan(); # Joshua Nathaniel Pritikin

Page 27: Perl Testing

sofort austauschen

# use Test; use Test::Legacy;

Page 28: Perl Testing

Test::Legacy::More # use Test; use Test::Legacy;

Page 29: Perl Testing

Test::Legacy use Test::Legacy; use Test::Legacy::More;

# use Test::More import => [ qw(!ok !skip !plan)];

Page 30: Perl Testing

Warum?

TAP : Test Anything Protocol

Page 31: Perl Testing

Wichtig!

Page 32: Perl Testing

Test::Simple

Page 33: Perl Testing

Test::Simple

use Test::Simple 'no_plan';

ok( $dies eq $das, 'dies gleich das' );

Page 34: Perl Testing

Test::Simple

use Test::Simple 'no_plan';

ok( $dies eq $das, 'dies gleich das' );

Vergleich Meldung (Name)

Page 35: Perl Testing

Test::Simplemake test # nur wenn Makefile da ist

Page 36: Perl Testing

Test::Simple

use Test::Simple 'no_plan';

ok( $dies eq $das, 'dies gleich das' );

ok( $dies == $das, 'numerisch gleich' );

Page 37: Perl Testing

Test::Simple

use Test::Simple tests => 2;

ok( $dies eq $das, 'dies gleich das' );

ok( $dies == $das, 'numerisch gleich' );

Page 38: Perl Testing

Test::Simplepackage Test::Simple;

use 5.006;use strict;

our $VERSION = '0.96';

use Test::Builder::Module;our @ISA = qw(Test::Builder::Module);our @EXPORT = qw(ok);

my $CLASS = __PACKAGE__;

Page 39: Perl Testing

Test::Betweenpackage Test::Between;

use base 'Exporter';our @EXPORT = qw( is_between);

use Test::Builder;my $test = Test::Builder->new();

sub is_between($$$;$) { my ($item, $lower, $upper, $name) = @_; return ( $test->ok(...) || $test->diag(„...“) );}1;

Page 40: Perl Testing

Test::More

wie Test::Simple

mehr Augabe

Page 41: Perl Testing

Test::More use Test::More 'no_plan'; # or skip_all => $reason;

ok, is, isnt, like, unlike, cmp_ok, is_deeply

use_ok, require_ok, can_ok, isa_ok, new_ok

SKIP, TODO, BAIL_OUT, subtest

diag, note, explain, pass, fail, done_testing

Page 42: Perl Testing

Test::More

ok, is, isnt, like, unlike, cmp_ok, is_deeply

Vergleiche: pos, eq, re, cmp, HoH....

Page 43: Perl Testing

Test::More

Module

use_ok, require_ok, can_ok, isa_ok, new_ok

Page 44: Perl Testing

Test::More

Steuern: überspringen, abbrechen, zusammenfassen

SKIP, TODO, BAIL_OUT, subtest

Page 45: Perl Testing

Test::More

Ausgabe: Warnungen(STDERR), Zählung

diag, note, explain, pass, fail, done_testing

Page 46: Perl Testing

Test::More use Test::More 'no_plan'; # or skip_all => $reason;

ok, is, isnt, like, unlike, cmp_ok, is_deeply

use_ok, require_ok, can_ok, isa_ok, new_ok

SKIP, TODO, BAIL_OUT, subtest

diag, note, explain, pass, fail, done_testing

Page 47: Perl Testing

Test::Most

Page 48: Perl Testing

Devel::Cover$ cover -testDeleting database /home/pjcj/g/perl/Shell-Source-0.01/cover_dbPERL_DL_NONLAZY=1 /usr/local/pkg/cover/c1/perl-5.8.7/bin/perl "-MExtUtils::Command::MM" \ "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.tt/bash....ok...All tests successful.Files=6, Tests=24, 17 wallclock secs (16.16 cusr + 1.01 csys = 17.17 CPU)Reading database from /home/pjcj/g/perl/Shell-Source-0.01/cover_db

------------------------------------------ ------ ------ ------ ------ ------ ------ ------File stmt bran cond sub pod time total------------------------------------------ ------ ------ ------ ------ ------ ------ ------blib/lib/Shell/Source.pm 96.6 65.0 66.7 90.9 n/a 100.0 86.1Total 96.6 65.0 66.7 90.9 n/a 100.0 86.1------------------------------------------ ------ ------ ------ ------ ------ ------ ------

Writing HTML output to /home/pjcj/g/perl/Shell-Source0.01/cover_db/coverage.html …done.

Page 49: Perl Testing

Devel::Cover

Page 50: Perl Testing

Test::TestCoverageuse Test::More;

eval { require Test::Pod::Coverage; import Test::Pod::Coverage;};

plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@;all_pod_coverage_ok();

Page 51: Perl Testing

Test::Pod::Coverageuse Test::More;

eval { require Test::Pod::Coverage; import Test::Pod::Coverage;};

plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@;all_pod_coverage_ok();

Page 52: Perl Testing

Test::Ifuse Test::More;use Test::If # Checked first $ENV{TEST_AUTHOR}, or skip sub { $ENV{TEST_AUTHOR} }, # Use Test::Pod::Coverage of at least version 1.08 'Test::Pod::Coverage 1.08', # And want Pod::Coverage at least of version 0.18 'Pod::Coverage 0.18',; all_pod_coverage_ok();

Page 53: Perl Testing

Test::Poduse Test::More;

eval { require Test::Pod; import Test::Pod;};

plan skip_all => "Test::Pod missing" if $@;all_pod_files_ok();

Page 54: Perl Testing

Test::Spelling

use Test::Spelling;use Test::More;

all_pod_files_spelling_ok();

Page 55: Perl Testing

Test::Spellinguse Test::Spelling;use Test::More;

add_stopwords();my @files = all_pod_files();pod_files_spelling_ok( @files, "POD file spelling OK" );

pod_file_spelling_ok( $file, "$file spelling OK" );

Page 56: Perl Testing

Test::Pod::Spelling::CommonMistakes

use Test::Spelling;use Test::More;

pod_file_ok( $file, "POD file spelling OK" );all_pod_files_ok();

Page 57: Perl Testing

Test::Strict

Page 58: Perl Testing

Test::Kwaliteeuse Test::More;

eval { require Test::Kwalitee; Test::Kwalitee->import()};

plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@;

Page 59: Perl Testing

Test::Kwalitee● extractable, no_symlinks

● has_readme, have_manifest, have_meta_yml

● have_buildtool, have_changelog, have_tests

● use_strict, proper_libs

● no_pod_errors, have_test_pod, have_test_pod_coverage

Page 60: Perl Testing

Test::Distribution

fast deckungsgleich mit Test::Kwalitee

Page 61: Perl Testing

Test::Module::Used use Test::Module::Used;

my $used = Test::Module::Used->new(); $used->ok;

Werden benutze Bibliotheken gefordert?Werden Geforderte Bibliohteken benutzt?

Page 62: Perl Testing

Test::CPANpm

simuliert einen CPAN install

kein ersatz für vorige Module

Page 63: Perl Testing

Test::Perl::Critic use Test::Perl::Critic; use Test::More tests => 1;

critic_ok($file);

all_critic_ok($dir_1, $dir_2, $dir_N);

all_critic_ok();

Page 64: Perl Testing

Test::Most use Test::More;

use Test::Differences;

use Test::Deep;

use Test::Exception;

use Test::Warn;

mehr ...

Page 65: Perl Testing

Test::Most use Test::More;

use Test::Differences;

use Test::Deep;

use Test::Exception;

use Test::Warn;

mehr ...

Page 66: Perl Testing

Test::Most● die_on_fail bail_on_fail● restore_fail set_failure_handler ● explain # prove -v● show

● all_done

Page 67: Perl Testing

Test::Most use Test::More;

use Test::Differences;

use Test::Deep;

use Test::Exception;

use Test::Warn;

mehr ...

Page 68: Perl Testing

Test::Differences

Page 69: Perl Testing

Test::Differencesuse Test::More;

is_deeply([1,2],[1,2,[3]], '… nicht gleich');

Page 70: Perl Testing

Test::Differencesuse Test::More;

is_deeply([1,2],[1,2,[3]], '… nicht gleich');

# Failed test 'is_deeply'# at t\02-more.t line 12.# Structures begin differing at:# $got->[3] = ARRAY(0xae3704)# $expected->[3] = Does not exist

Page 71: Perl Testing

Test::Differencesuse Test::More tests => 1;use Test::Differences;

eq_or_diff([1,2],[1,2,[3]], '… nicht gleich');

Page 72: Perl Testing

Test::Differencesuse Test::Most tests => 1;

eq_or_diff([1,2],[1,2,[3]], '… nicht gleich');

Page 73: Perl Testing

Test::Differences# Failed test '...nicht gleich' eq_or_diff([1,2],[1,2,[3]]# at t\04-diff.t line 8.# +----+------+----+------------+# | Elt|Got | Elt|Expected |# +----+------+----+------------+# | 0|[ | 0|[ |# | 1| 1, | 1| 1, |# * 2| 2 * 2| 2, *# | | * 3| [ *# | | * 4| 3 *# | | * 5| ] *# | 3|] | 6|] |# +----+------+----+------------+

Page 74: Perl Testing

Test::Differences4 Anzeigestile:

* table_diff; #(the default) * unified_diff; * oldstyle_diff; * context_diff;

Page 75: Perl Testing

Test::Differences# Failed test '...nicht gleich' unified_diff;# at t\04-diff.t line 8. eq_or_diff([1,2],[1,2,[3]]# --- Got # +++ Expected# @@ -1,4 +1,7 @@# [# 1,# - 2# + 2,# + [# + 3# + ]

Page 76: Perl Testing

Test::Differences# Failed test '...nicht gleich' oldstyle_diff;# at t\04-diff.t line 8. eq_or_diff([1,2],[1,2,[3]]# 3c3,6 # < 2# ---# > 2,# > [# > 3# > ]

Page 77: Perl Testing

Test::Differences# *** Got context_diff;# --- Expected eq_or_diff([1,2],[1,2,[3]]# ***************# *** 1,4 ****# [# 1,# ! 2# ]# --- 1,7 ----# [# 1,# ! 2,# ! [# ! 3# ! ]# ]

Page 78: Perl Testing

Test::Differencesuse Test::More; # oder Testuse Test::Differences; # use Text::Diff;

eq_or_diff($gegeben, $gesucht, $meldung);# autoselect:eq_or_diff_data($gegeben, $gesucht, $meldung);eq_or_diff_text($gegeben, $gesucht, $meldung);

Page 79: Perl Testing

Test::Moreuse Test::More;

is_deeply([1,2],[1,2,[3]], '… nicht gleich');

Page 80: Perl Testing

Test::Moreuse Test::More;

is_deeply([1,2],[1,2,[3]], '… nicht gleich');

eq_array();eq_hash();eq_set();

Page 81: Perl Testing

Test::Moreuse Test::More;

is_deeply([1,2],[1,2,[3]], '… nicht gleich');

eq_array();eq_hash();eq_set();

Page 82: Perl Testing

Test::Deepuse Test::More 'no_plan';use Test::Deep;

cmp_deeply($got, $expected, $name); # is_deeply

not ok 1 – test name# Failed test 'test name'# at t\03-deep.t line 7.# Compared $data->[3][2][0]# got : '2'# expect : '1'

Page 83: Perl Testing

Test::Deepuse Test::Most 'no_plan';

cmp_deeply($got, $expected, $name); # is_deeplyeq_deeply($got, $expected); # no testcmp_bag(\@got, \@bag, $name); # Reihenfolge egal cmp_set(\@got, \@set, $name); # Mehrfache mögl.cmp_methods(\@got, \@methods, $name);

Page 84: Perl Testing

Test::Deepuse Test::Most 'no_plan';

cmp_deeply($got, $expected, $name); # is_deeplyeq_deeply($got, $expected); # no testcmp_bag(\@got, \@bag, $name); # bag wie in P6 cmp_set(\@got, \@set, $name); # eq_setcmp_methods(\@got, \@methods, $name);

Page 85: Perl Testing

Aliaseuse Test::Deep;

cmp_bag(\@got, \@bag, $name);cmp_deeply(\@got, bag(@exp), $name);

cmp_set(\@got, \@set, $name);cmp_deeply(\@got, set(@exp), $name);

cmp_methods($obj, \@exp, $name);cmp_deeply($obj, methods(%exp), $name);

Page 86: Perl Testing

kombinierbare Befehle

cmp_deeply(\@got, bag(@exp), $name);

cmp_deeply(\@got, set(@exp), $name);

cmp_deeply($obj, methods(%exp), $name);

Page 87: Perl Testing

kombinierbare Befehle

bag(@exp)

set(@exp)

methods(%exp)

Page 88: Perl Testing

kombinierbare Befehleignore()any(@exp) / all(@exp)bag(@exp)set(@exp)super|sub . hash|bag|set . of ()array_eachstr / num / bool / codere(@exp)shallow($ref)methods(@exp)listmethods(@exp)noclass(@exp)useclass(@exp)isa(@exp)

Page 89: Perl Testing

Test::Deep::NoTest

use Test::Deep::NoTest;

Page 90: Perl Testing

Test::Exception

use Test::Exception;

throws_ok( {...}, $ausnahmeklasse, $name);throws_ok( {...}, $regex, $name);lives_ok( {…}, $name);dies_ok({...}, $name);

Page 91: Perl Testing

Test::Warn# Welche Warnungen wurden ausgegeben?

use Test::Warn;

warning_is( {...} $warnung, $name);warnings_are( {...} @warnungen, $name);

warning_like();

Page 92: Perl Testing

Test::Most use Test::More;

use Test::Differences;

use Test::Deep;

use Test::Exception;

use Test::Warn;

mehr … fertig

Page 93: Perl Testing

Bundle::Test Test Test::Simple Test::More Test::Harness Test::MockObject Test::Pod Test::Builder Test::Warn Test::Inline Test::Strict Test::Distribution Test::Perl::Critic Test::Kwalitee Pod::Spell Test::Spelling Devel::Cover ...

Page 94: Perl Testing

Test::NoWarnings

use Test::NoWarnings;

Page 95: Perl Testing

Test::NoWarnings

use Test::NoWarnings;

# $plan += 1

>ok $plan - no warnings

Page 96: Perl Testing

Test::Script

use Test::Script;

script_compiles();

script_runs();

Page 97: Perl Testing

Test::Cmduse Test::Cmd;

my $cmd = Test::Cmd->new ( prog => 'prog.pl', interpreter => 'script_interpreter', string => 'identifier_string', workdir => '', subdir => 'dir', match_sub => $code_ref, verbose => 1, ...);

$cmd->write( # Datei schreiben$cmd->run( # $? == 0

Page 98: Perl Testing

Test::Expect expect_run ( command => "cpan", prompt => 'install Kephra', quit => 'q', );expect_like(qr/install UNINST=1 -- OK/, "gut");

expect_handle();

Page 99: Perl Testing

Test::Timeruse Test::Timer;

time_ok, time_atmost time_betweentime_atleast

time_between

Page 100: Perl Testing

Test::Benchmark

use Test::Timer;

is_faster($times, $sub1, $sub2, $name);is_n_times_faster($factor, $t, $sub1, $sub2, $name);is_fastest();

Page 101: Perl Testing

Test::ManyParamsuse Test::ManyParams;

all_ok { tannu(shift) }, @para, $nachricht;all_ok { tuwas(@_) }, [ @a, @b], $nachricht;

qw(all any) X~ qw(ok is isnt) most_ok{ sub(@_) }, [ @a, @b] => $nr, $nachricht;

Page 102: Perl Testing

Randomuse File::Random;

my $random_gif = random_file(-dir => $dir,

-check => qr/\.gif$/, -recursive => 1);

use Data::Random;

Page 103: Perl Testing

Win32::GuiTest

SendKeys();

MouseMoveAbsPix(100, 200);SendMouse();

Page 104: Perl Testing

Win32::Screenshot

Page 105: Perl Testing

Test::Data

use Test::Data qw(Scalar Array Hash Function);

Page 106: Perl Testing

Test::Data::Scalarblessed_okdefined_okundef_ok

greater_thanless_thanlength_ok

maxlength_okminlength_oknumber_ok

Page 107: Perl Testing

Test::LongStringuse Test::LongString max => 100; # 50 ist default

is_stringis_string_nowscontains_stringlacks_stringlike_stringunlike_string

Page 108: Perl Testing

Test::LongStringuse Test::LongString max => 100; # 50 ist default

is_string # Failed test (html-test.t at line 12) # got: "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Trans"... # length: 58930 # doesn't match '(?-xism:(perl|cpan)\.org)'

Page 109: Perl Testing

Test::LongStringuse Test::LongString max => 100; # 50 ist default

like_string# Failed test (soliloquy.t at line 15)# got: "To be, or not to be: that is the question:\x{0a} Wh" ...# length: 1490# doesn't match '(?-xism:Romeo|Juliet|Mercutio|Tybalt)'

Page 110: Perl Testing

Test::Outputstdout_is

stderr_isnt

output_iscombined_is

stdout_likestdout_unlike

Page 111: Perl Testing

Test::Carp

does_carp(\&function);

does_carp_that_matches(\&function, qr/whoopsy/);

Page 112: Perl Testing

Test::Log4perl

Test::Log::Dispatch

Page 113: Perl Testing

Test Techniken

Page 114: Perl Testing

analyze this

Page 115: Perl Testing

Mocking

Page 116: Perl Testing

Mocking

Test::MockModule

Test::MockObject

Test::MockObject::Extends

DBD::Mock

Page 117: Perl Testing

Test::MockModuleuse Module::Name;use Test::MockModule;

{ my $module = new Test::MockModule('Module::Name'); $module->mock('subroutine', sub { ... }); Module::Name::subroutine(@args); # mocked} Module::Name::subroutine(@args); # unverändert

Page 118: Perl Testing

Test::MockObject

use

Page 119: Perl Testing

Test::MockObject::Extends

use

Page 120: Perl Testing

Devel::Hide

use Devel::Hide qw[Test::Most];

use Tests::Most; # error

Page 121: Perl Testing

Test::Without::Module

use Test::Without::Module qw[Test::Most];

use Tests::Most; # error

Page 122: Perl Testing

Test::Without

run { ... } without 'Net::Server';

run { ... } with 'Net::Server';

Page 123: Perl Testing

Organisation

Page 124: Perl Testing

Test::Standaloneuse Test::Standalone;

=begin test .... .... =end test

script.pl --test

Page 125: Perl Testing

Test::Inline

=begin testing label ... normaler Testcode .... .... =end testing

Page 126: Perl Testing

Test::Inline

=begin testing label .... .... =end testing

inline2test.pl

Page 127: Perl Testing

Test::Plan

plan tests => 3, need need_module('Kephra'), need_min_module_version(Wx => 0.9), need_min_perl_version(5.6);

Page 128: Perl Testing

Test::Blockuse Test::More 'no_plan';use Test::Block qw($Plan);

{local $Plan = 2;

}

Page 129: Perl Testing

Test::Groupuse Test::More no_plan;use Test::Group;

test "tausend tests" => sub {ok(1,'—') for 1..1000;

};

----------------------------------------------------------

ok 1 - tausend tests1..1

Page 130: Perl Testing

Unit-Testing

Page 131: Perl Testing

Test::Unit # starte und räume aufsub set_up { ... }sub tear_down { ... }

# eigentliche testssub test_... { ... {}

# starte alle testscreate_suite();run_suite();

Page 132: Perl Testing

Test::Unit

use Test::Unit; # 2001

Page 133: Perl Testing

Test::Unit::Lite

use Test::Unit::Lite; # 2009

Page 134: Perl Testing

Test::SimpleUnit

Page 135: Perl Testing

Test::Extreme

use TestConfigs;use TestAPI;use TestOutput;

run_tests 'TestConfigs', 'TestAPI', 'TestOutput';

Page 136: Perl Testing

Test::Extreme

use Test::Extreme;

sub foo { return 23 };sub test_foo { assert_equals foo, 23 }

Page 137: Perl Testing

Test::Classpackage Meine::Test::Klasse;use base qw(Test::Class);

sub eats : Test(3) {

Meine::Test::Klasse->runtests

Page 138: Perl Testing

Test::Classpackage Meine::Test::Klasse;

sub eats : Test(3) {

package main;Meine::Test::Klasse->runtests;

Page 139: Perl Testing

Test::Class

BEGIN { chdir 't' if -d 't'; require Meine::Test::Klasse;}

Meine::Test::Klasse->runtests;

# Meine/Test/Klasse.pm

Page 140: Perl Testing

Test::Class

sub tischlein_deck_dich : Test (startup) {sub knueppel_aus_dem_sack : Test (shutdown) {

sub neues_tischtuch : Test (setup => 2 ) {sub abraeumkommando : Test (teardown) {

Page 141: Perl Testing

Test::Class::Sugar

use Test::Class::Sugar;

Page 142: Perl Testing

Test::Able

Page 143: Perl Testing

Test::Able

Page 144: Perl Testing

Test::Able package MyTest;

use Test::Able; use Test::More;

startup some_startup => sub { ... }; setup some_setup => sub { ... }; test plan => 1, foo => sub { ok( 1 ); }; test bar => sub { my @runtime_list = 1 .. 42; $_[ 0 ]->meta->current_method->plan( scalar @runtime_list ); ok( 1 ) for @runtime_list; }; teardown some_teardown => sub { ... }; shutdown some_shutdown => sub { ... };

MyTest->run_tests;

Page 145: Perl Testing

Test::Able use Test::Able::Helpers qw( shuffle_methods );

$t->meta->test_methods( [ grep { $_->name !~ /bar/; }

@{ $t->meta->test_methods } ] );

for ( 1 .. 10 ) { $t->shuffle_methods; $t->run_tests;}

Page 146: Perl Testing

Gutes Buch

Page 147: Perl Testing

Linkshttp://www.slideshare.net/lichtkind

search.cpan.org/dist/Test-Simple/lib/Test/Tutorial.pod

.../dist/Test-Able/lib/Test/Able/Cookbook.pm

http://qa.perl.org/testing/

http://www.cpantesters.org/

http://testanything.org

http://docs.racket-lang.org/rackunit

Page 148: Perl Testing

Glückliches Ende