Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Software Testing

54 views

Published on

All you need is two functions. Testing should be easy. The Test Anything Protocol makes it easy to do testing with just two just two functions.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Software Testing

  1. 1. software Testing Presented by Lambert Lum All you need is two functions
  2. 2. Test Anything Protocol Test Anything Protcol (TAP) Lets you do all your testing with two functions
  3. 3. Supported Languages Perl Python PHP Ruby JavaScript C C++ Java Forth
  4. 4. Perl Our presentation will use Perl
  5. 5. How many tests use Test::More tests => 1;
  6. 6. done_testing() # Can't be bothered to specify number of tests done_testing(); # bottom of test script
  7. 7. ok() use Test::More tests => 1; my $bool = 1; ok ($bool, "boolean test");
  8. 8. is() use Test::More tests => 1; my $got = 5 * 2; my $expected = 10; is ($got, $expected, "got equals expected");
  9. 9. We’re done All you need is ok() and is() Let’s all go home.
  10. 10. What? You’re Still here? Seriously, everything can be done with ok() and is() It’s that simple
  11. 11. Wait! There’s more The following slides have optional, but nice features
  12. 12. prove # run all the test scripts in the t directory $ prove t
  13. 13. prove $ prove t t/done_testing.t .. ok t/is.t ............ ok t/ok.t ............ ok t/ok_is.t ......... ok All tests successful. Files=4, Tests=5, 0 wallclock secs ( 0.04 usr 0.00 sys + 0.20 cusr 0.01 csys = 0.25 CPU) Result: PASS
  14. 14. prove # run test scripts in parallel $ prove --jobs 9 t
  15. 15. prove # parallelize optimally $ prove --jobs 9 --state=save,slow t
  16. 16. Test::Harness The prove command is part of Test::Harness
  17. 17. eq_or_diff For comparing deeply nested data structures. Will produce side-by-side diffs on fail.
  18. 18. eq_or_diff use Test::More tests => 1; use Test::Differences qw(eq_or_diff); eq_or_diff ( $hash, { name => 'Jagermech', armament => { RA => ['Autocannon 2', 'LRM 15'], }, }, "comparing data structures", );
  19. 19. Test::Exception dies_ok ( sub { die "now dieing"; }, "die"); lives_ok ( sub { }, "no die");
  20. 20. Test::Fatal Simpler alternative to Test::Exception Lambert has no practice in this
  21. 21. Test::BDD::Cucumber Gives an English-like way for project managers to write test Lambert hasn’t used it
  22. 22. Test::Pod For testing your POD documentation Lambert has no practice in this
  23. 23. Supplementary info The following slides are not part of Test Anything Protocol They are still useful, though
  24. 24. Devel::Cover Coverage testing Lambert has no practice in this
  25. 25. Devel::NYTProf Profiling on per-line and per-subroutine Produces HTML web pages

×