Also posted to http://www.perlmonks.org/?node_id=592527.

I'm planning, within the next couple of weeks or so, to release a new
version of TAPx::Parser. Amongst other things, I have two test
harnesses now included with it (one is a subclass of the other which
allows test output to be colorized). Along with this, I have a runtests
utility, similar to prove. Here's the start of the docs for runtests
(these are the features which are implemented.  More will be added
later):

  NAME

  runtests - Run tests through a TAPx harness.

  USAGE

    runtests [options] [files or directories]

  OPTIONS

  Boolean options

    -v,  --verbose     Print all test lines.
    -l,  --lib         Add 'lib' to the path for your tests.
    -b,  --blib        Add 'blib/lib' to the path for your tests.
    -s,  --shuffle     Run the tests in random order.
    -c,  --color       Color test output.  See TAPx::Harness::Color.
    -f,  --failures    Only show failed tests.
    -m,  --merge       Merge STDERR and STDOUT
    -r,  --recurse     Recursively descend into directories.

  Options which take arguments

    -h,  --harness     Define test harness to use.  See TAPx::Harness.

Note that the colored test output and 'show only failures' are two
features people have long wanted but are relatively tricky to implement
due to the current architecture of Test::Harness. Some of the features
I'm planning:

    * Show which tests unexpectedly succeeded.
    * Include a --directives switch which only displays test lines with
directives attached (handy for generating TODO lists).
    * exec: tell the harness how to output TAP for a given file.

The exec feature might be one of the most important. With that,
anything can be tested. For example, imagine the following Perl program
we'll call test_html:

  #!/usr/bin/perl

  use Test::HTML::Lint tests => 1;

  my $file = shift;
  open my $fh, '<', $file
    or die "Cannot open ($file) for reading: $!";
  my $html = do { local $/; <$fh> };
  
  html_ok( $html, "$file has valid HTML" );
 
With the above, you could do this:

  runtests --recurse --exec 'run_tests %s' www/

Congratulations! You've just converted all of your HTML documents into
tests. Or, at least that's the intention :)

What else would you like to see in a new test framework for Perl?
People have told me they need XML generated (I can't think of a way to
do this generically, though I have the pieces in place to make it easy
to write), GUIs, and emailing test failures. What would you like?

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/

Reply via email to