Evolving Tests

675 views
613 views

Published on

This presentation traces my evolutionary path through software unit-testing techniques. The examples are in Perl, but the concepts can be applied to other programming languages as well. This material was first presented to the San Francisco Perl Mongers in February 2009.

Published in: Technology, Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
675
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
28
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Evolving Tests

  1. 1. Jeffrey Thalhammer S o f t w a r e S y s t e m s jeff@imaginative-software.com
  2. 2. Evolving Tests Apple Gung-Ho April 9, 2009
  3. 3. In The Beginning...
  4. 4. Let’s Say We Have Some Code We Want To Test
  5. 5. #!/usr/bin/perl use strict; use warnings; use criticism; use Car; my $car = Car->new(); $car->start_motor(); $car->accelerate(mps2 => 20); $car->steer(degrees => -34); my ($lat, $long) = $car->current_position()
  6. 6. #!/usr/bin/perl use strict; use warnings; use criticism; We have a car class use Car; my $car = Car->new(); $car->start_motor(); $car->accelerate(mps2 => 20); $car->steer(degrees => -34); my ($lat, $long) = $car->current_position()
  7. 7. #!/usr/bin/perl use strict; use warnings; use criticism; use Car; Make a new car my $car = Car->new(); $car->start_motor(); $car->accelerate(mps2 => 20); $car->steer(degrees => -34); my ($lat, $long) = $car->current_position()
  8. 8. #!/usr/bin/perl use strict; use warnings; use criticism; use Car; my $car = Car->new(); Fire it up $car->start_motor(); $car->accelerate(mps2 => 20); $car->steer(degrees => -34); my ($lat, $long) = $car->current_position()
  9. 9. #!/usr/bin/perl use strict; use warnings; use criticism; use Car; my $car = Car->new(); $car->start_motor(); $car->accelerate(mps2 => 20); Step on the gas $car->steer(degrees => -34); my ($lat, $long) = $car->current_position()
  10. 10. #!/usr/bin/perl use strict; use warnings; use criticism; use Car; my $car = Car->new(); $car->start_motor(); $car->accelerate(mps2 => 20); $car->steer(degrees => -34); Change direction my ($lat, $long) = $car->current_position()
  11. 11. #!/usr/bin/perl use strict; use warnings; use criticism; use Car; my $car = Car->new(); $car->start_motor(); $car->accelerate(mps2 => 20); $car->steer(degrees => -34); my ($lat, $long) = $car->current_position() Query location
  12. 12. #!/usr/bin/perl use strict; use warnings; use criticism; use Car; my $car = Car->new(); $car->start_motor(); $car->accelerate(mps2 => 20); $car->steer(degrees => -34); my ($lat, $long) = $car->current_position()
  13. 13. And So Begins Our Journey Through Time
  14. 14. The Paleozoic Era
  15. 15. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  16. 16. #!/usr/bin/perl Tests written in scripts use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  17. 17. #!/usr/bin/perl use Test::More (tests => 4); Use Test::More use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  18. 18. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); Create an object isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  19. 19. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); Manipulate the object $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  20. 20. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); Make some assertions is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  21. 21. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  22. 22. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); No structure my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  23. 23. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); Variables recycled $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  24. 24. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); Hardcoded values is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  25. 25. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); Can’t reuse code my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  26. 26. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); Just doesn’t scale my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  27. 27. #!/usr/bin/perl use Test::More (tests => 4); use_ok(‘Car’); my $car = Car->new(); isa($car, ‘Car’); $car = Car->new(lat => 12, long => 46); $car->accelerate(mps2 => 20); my($lat, $long) = $car->current_position(); is($lat, 23.12, ‘Correct latitude’); is($long, 48.61, ‘Correct longitude’);
  28. 28. Extinction By Asteroid
  29. 29. The Mesozoic Era
  30. 30. #!/usr/bin/perl sub test_new { my $car = Car->new(); isa($car, ‘Car’); } sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- test_new (); test_acceleration(); ...
  31. 31. #!/usr/bin/perl Still written in scripts sub test_new { my $car = Car->new(); isa($car, ‘Car’); } sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- test_new (); test_acceleration(); ...
  32. 32. #!/usr/bin/perl sub test_new { my $car = Car->new(); isa($car, ‘Car’); Organize tests } into subroutines sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- test_new (); test_acceleration(); ...
  33. 33. #!/usr/bin/perl sub test_new { my $car = Car->new(); isa($car, ‘Car’); } sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- Then call each test_new (); subroutine test_acceleration(); ...
  34. 34. #!/usr/bin/perl sub test_new { my $car = Car->new(); isa($car, ‘Car’); } sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- test_new (); test_acceleration(); ...
  35. 35. #!/usr/bin/perl sub test_new { my $car = Car->new(); isa($car, ‘Car’); Must remember } to call test subs sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- test_new (); test_acceleration(); ...
  36. 36. #!/usr/bin/perl sub test_new { my $car = Car->new(); isa($car, ‘Car’); Still can’t reuse } code sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- test_new (); test_acceleration(); ...
  37. 37. #!/usr/bin/perl sub test_new { my $car = Car->new(); isa($car, ‘Car’); } sub test_acceleration { my $car = Car->new(...); my ($lat, $long) = $car->accelerate(mps2 => 12); is($lat, 34.5, ‘Correct latitude’); } ... #--------------------------------------------- test_new (); test_acceleration(); ...
  38. 38. Extinction By Ice Age
  39. 39. The Cenozoic Era
  40. 40. Test::Class By Adrian Howard “Easily create test classes in an xUnit/JUnit style” http://search.cpan.org/dist/Test-Class/
  41. 41. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  42. 42. package Test::Car; Tests are modules use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  43. 43. package Test::Car; Inherit from use base ‘Test::Class’; Test::Class sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  44. 44. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { “Setup” method my $self = shift; creates test fixture my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  45. 45. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); Construct our test car $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  46. 46. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } It’s just a blessed hash sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  47. 47. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { “Test” methods my $self = shift; declare test count my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  48. 48. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; Getting the test fixture my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  49. 49. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); Do stuff with the car my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  50. 50. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... } Make some assertions
  51. 51. package Test::Car; use base ‘Test::Class’; sub setup : Test(setup) { my $self = shift; my $car = Car->new(); $self->{car} = $car; } sub test_acceleration : Test(3) { my $self = shift; my $car = $self->{car}; $car->accelerate(mps2 => 34); my($lat, $long) = $car->current_position(); is($lat, 32.6, ‘Straight-line acceleration’); ... }
  52. 52. But How Do You Run It?
  53. 53. But How Do You Run It? #!/usr/bin/perl use Test::Car; Test::Car->runtests();
  54. 54. But How Do You Run It? #!/usr/bin/perl Load our test class use Test::Car; Test::Car->runtests();
  55. 55. But How Do You Run It? #!/usr/bin/perl Runs all the use Test::Car; “Test” methods Test::Car->runtests();
  56. 56. But How Do You Run It? #!/usr/bin/perl use Test::Car; Test::Car->runtests();
  57. 57. Suppose We Make A Subclass Of ‘Car’ package Car::Convertible; use base ‘Car’; sub open_roof { my $self = shift; $self->(mps2 => 5); ... }
  58. 58. Suppose We Make A Subclass Of ‘Car’ package Car::Convertible; use base ‘Car’; Inherit from Car sub open_roof { my $self = shift; $self->(mps2 => 5); ... }
  59. 59. Suppose We Make A Subclass Of ‘Car’ package Car::Convertible; use base ‘Car’; sub open_roof { Add new functionality my $self = shift; $self->(mps2 => 5); ... }
  60. 60. Suppose We Make A Subclass Of ‘Car’ package Car::Convertible; use base ‘Car’; sub open_roof { my $self = shift; $self->(mps2 => 5); ... }
  61. 61. Since Tests Are Now Classes, We Can Subclass Them Too!!
  62. 62. Making Test Classes More Inheritable package Test::Car; use base ‘Test::Class’; sub class_under_test { return ‘Car’; } sub setup : Test(setup) { my $self = shift; my $class = $self->class_under_test(); eval “require $class”; my $car = $class->new(); $self->{car} = $car; }
  63. 63. Making Test Classes More Inheritable package Test::Car; use base ‘Test::Class’; sub class_under_test { Declare class name return ‘Car’; in a method } sub setup : Test(setup) { my $self = shift; my $class = $self->class_under_test(); eval “require $class”; my $car = $class->new(); $self->{car} = $car; }
  64. 64. Making Test Classes More Inheritable package Test::Car; use base ‘Test::Class’; sub class_under_test { return ‘Car’; } Use it to construct sub setup the fixture : Test(setup) { my $self = shift; my $class = $self->class_under_test(); eval “require $class”; my $car = $class->new(); $self->{car} = $car; }
  65. 65. Making Test Classes More Inheritable package Test::Car; use base ‘Test::Class’; sub class_under_test { return ‘Car’; } sub setup : Test(setup) { my $self = shift; my $class = $self->class_under_test(); eval “require $class”; my $car = $class->new(); $self->{car} = $car; }
  66. 66. Making Test Subclasses package Test::Car::Convertible; use base ‘Test::Car’; sub class_under_test { return ‘Car::Convertible’; } sub test_open_roof : Test(3) {...}
  67. 67. Making Test Subclasses package Test::Car::Convertible; Inherit from our use base ‘Test::Car’; test class sub class_under_test { return ‘Car::Convertible’; } sub test_open_roof : Test(3) {...}
  68. 68. Making Test Subclasses package Test::Car::Convertible; use base ‘Test::Car’; Override the name of sub class_under_test { the class we’re testing return ‘Car::Convertible’; } sub test_open_roof : Test(3) {...}
  69. 69. Making Test Subclasses package Test::Car::Convertible; use base ‘Test::Car’; sub class_under_test { return ‘Car::Convertible’; Add class-specific test } method sub test_open_roof : Test(3) {...}
  70. 70. Making Test Subclasses package Test::Car::Convertible; use base ‘Test::Car’; sub class_under_test { return ‘Car::Convertible’; } sub test_open_roof : Test(3) {...}
  71. 71. Making Test Subclasses package Test::Car::Convertible; use base ‘Test::Car’; sub class_under_test { return ‘Car::Convertible’; } sub test_open_roof : Test(3) {...} #!/usr/bin/perl use Test::Car::Convertible; Test::Car::Convertible->runtests();
  72. 72. Making Test Subclasses package Test::Car::Convertible; use base ‘Test::Car’; sub class_under_test { return ‘Car::Convertible’; } sub test_open_roof : Test(3) {...} #!/usr/bin/perl All the inherited tests will run too! use Test::Car::Convertible; Test::Car::Convertible->runtests();
  73. 73. Making Test Subclasses package Test::Car::Convertible; use base ‘Test::Car’; sub class_under_test { return ‘Car::Convertible’; } sub test_open_roof : Test(3) {...} #!/usr/bin/perl use Test::Car::Convertible; Test::Car::Convertible->runtests();
  74. 74. The Paleogene Period
  75. 75. The Paleogene Period use Moose;
  76. 76. Subclass In Other Dimensions Too! package Test::Car::FlatTire; use base ‘Test::Car’; sub setup : Test(setup) { my $self = shift; $self->SUPER::setup(@_); my $car = $self->{car}; $car->puncture( tires => [1,3] ); }
  77. 77. Subclass In Other Dimensions Too! package Test::Car::FlatTire; use base ‘Test::Car’; Inherit from base test class sub setup : Test(setup) { my $self = shift; $self->SUPER::setup(@_); my $car = $self->{car}; $car->puncture( tires => [1,3] ); }
  78. 78. Subclass In Other Dimensions Too! package Test::Car::FlatTire; use base ‘Test::Car’; sub setup : Test(setup) { Define custom setup method my $self = shift; $self->SUPER::setup(@_); my $car = $self->{car}; $car->puncture( tires => [1,3] ); }
  79. 79. Subclass In Other Dimensions Too! package Test::Car::FlatTire; use base ‘Test::Car’; sub setup : Test(setup) { my $self = shift; $self->SUPER::setup(@_); Call setup in superclass my $car = $self->{car}; $car->puncture( tires => [1,3] ); }
  80. 80. Subclass In Other Dimensions Too! package Test::Car::FlatTire; use base ‘Test::Car’; sub setup : Test(setup) { my $self = shift; $self->SUPER::setup(@_); my $car = $self->{car}; $car->puncture( tires => [1,3] ); } Modify the test fixture
  81. 81. Subclass In Other Dimensions Too! package Test::Car::FlatTire; use base ‘Test::Car’; sub setup : Test(setup) { my $self = shift; $self->SUPER::setup(@_); my $car = $self->{car}; $car->puncture( tires => [1,3] ); }
  82. 82. Data-Driven Testing package Test::TestDrive; use base ‘Test::Class’; sub test_drive Test(no_plan) {...} sub expected_waypoints { return ( [ 12.8, 34.6 ], [ 34.2, 56.2 ], [ 67.1, 1.38 ], ... ); }
  83. 83. Data-Driven Testing package Test::TestDrive; use base ‘Test::Class’; sub test_drive Test(no_plan) {...} sub expected_waypoints { Assume we have a return ( method that drives the [ 12.8, 34.6 ], car and tests its location [ 34.2, 56.2 ], at several points [ 67.1, 1.38 ], ... ); }
  84. 84. Data-Driven Testing package Test::TestDrive; use base ‘Test::Class’; sub test_drive Test(no_plan) {...} sub expected_waypoints { return ( [ 12.8, 34.6 ], Declare the expected [ 34.2, 56.2 ], locations in a method [ 67.1, 1.38 ], ... ); }
  85. 85. Data-Driven Testing package Test::TestDrive; use base ‘Test::Class’; sub test_drive Test(no_plan) {...} sub expected_waypoints { return ( [ 12.8, 34.6 ], [ 34.2, 56.2 ], [ 67.1, 1.38 ], ... ); }
  86. 86. Putting It All Together package Test::TestDrive::ConvertibleWithFlatTire; use base qw(Test::Car::Convertible Test::FlatTire Test::TestDrive); sub expected_waypoints { return ( [ 12.8, 34.6 ], [ 34.2, 56.2 ], [ 67.1, 1.38 ], ... ); }
  87. 87. Putting It All Together package Test::TestDrive::ConvertibleWithFlatTire; use base qw(Test::Car::Convertible Test::FlatTire Inherit from several Test::TestDrive); base classes sub expected_waypoints { return ( [ 12.8, 34.6 ], [ 34.2, 56.2 ], [ 67.1, 1.38 ], ... ); }
  88. 88. Putting It All Together package Test::TestDrive::ConvertibleWithFlatTire; use base qw(Test::Car::Convertible Test::FlatTire Test::TestDrive); sub expected_waypoints { return ( Override methods that [ 12.8, 34.6 ], declare the expected [ 34.2, 56.2 ], results [ 67.1, 1.38 ], ... ); }
  89. 89. Putting It All Together package Test::TestDrive::ConvertibleWithFlatTire; use base qw(Test::Car::Convertible Test::FlatTire Test::TestDrive); sub expected_waypoints { return ( [ 12.8, 34.6 ], [ 34.2, 56.2 ], [ 67.1, 1.38 ], ... ); }
  90. 90. The Neogene Period
  91. 91. Look Mom, No Test Scripts! #!/usr/bin/perl use strict; use warnings; use Test::Class::Load 'tlib'; Test::Class->runtests();
  92. 92. Look Mom, No Test Scripts! #!/usr/bin/perl Finds all the use strict; modules in “tlib” use warnings; directory use Test::Class::Load 'tlib'; Test::Class->runtests();
  93. 93. Look Mom, No Test Scripts! #!/usr/bin/perl use strict; use warnings; use Test::Class::Load 'tlib'; Test::Class->runtests(); Runs all the tests
  94. 94. Look Mom, No Test Scripts! #!/usr/bin/perl use strict; use warnings; use Test::Class::Load 'tlib'; Test::Class->runtests();
  95. 95. Running Individual Tests $> TEST_METHOD=foo prove t/classes.t
  96. 96. Running Individual Tests $> TEST_METHOD=foo prove t/classes.t Using “prove” as the test harness
  97. 97. Running Individual Tests $> TEST_METHOD=foo prove t/classes.t Loads and runs my test modules
  98. 98. Running Individual Tests $> TEST_METHOD=foo prove t/classes.t Only methods matching /foo/ will run
  99. 99. Running Individual Tests $> TEST_METHOD=foo prove t/classes.t
  100. 100. The Future??
  101. 101. Unless...
  102. 102. For More Discussion http://www.modernperlbooks.com
  103. 103. Jeffrey Thalhammer S o f t w a r e S y s t e m s jeff@imaginative-software.com

×