Test::AtRuntime - Put tests in your code and run them as your program runs


Test-AtRuntime documentation  | view source Contained in the Test-AtRuntime distribution.

Index


NAME

Top

Test::AtRuntime - Put tests in your code and run them as your program runs

SYNOPSIS

Top

  use Test::AtRuntime 'logfile';
  use Test::More;

  sub foo {
      # This test runs.
      TEST { pass('foo ran'); }
  }

  no Test::AtRuntime;

  sub bar {
      # This test is not run.
      TEST { pass('bar ran') }
  }

  foo();
  bar();

DESCRIPTION

Top

Test::AtRuntime lets you use Test::More and other Test::Builder based modules directly in your source code providing a way to test your program as it runs. Similar to the concept of an assertion, except instead of dying when it fails, normal "not ok" output will be seen.

Compiling out

Like assertions, they can be turned on or off as needed. Tests are put inside of a TEST block like so:

    TEST { like( $totally, qr/rad/ ) }

use Test::AtRuntime runs these tests. no Test::AtRuntime means these tests will not be run. In fact, they will be completely removed from the program so that performance will not be effected (except some startup performance for the filtering).

Logfile

use Test::AtRuntime takes an argument, a logfile to append your tests to. If no logfile is given, tests will be outputed like normal.

CAVEATS

Top

Due to what appears to be a bug in Filter::Simple, this won't work as expected:

    use Test::AtRuntime;

    ...run tests...




    no Test::AtRuntime;

    ...don't run tests...

    use Test::AtRuntime;

    ...run tests...  <--- BUG

Once you stop running tests, they can't be made to run again.

TODO

Top

* suppress ok

It'll probably be useful to suppress the 'ok' messages so only failures are seen. Then again, "tail -f logfile | grep '^ok '" does a good job of that. Also, Test::Builder doesn't support that yet.

* honor environment variables

Test::AtRuntime should honor the same NDEBUG and PERL_NDEBUG environment variables as Carp::Assert and possibly an additional one just for Test::AtRuntime.

* stack trace on failure

Failing test should be accompanied by a stack trace to help figure out what's going wrong.

SEE ALSO

Top

Test::More, Carp::Assert, Carp::Assert::More, Test::Inline, Test::Class


Test-AtRuntime documentation  | view source Contained in the Test-AtRuntime distribution.