Test::Inline is a Perl module to embed your tests in your code, next to what is being tested.
Embedding tests allows tests to be placed near the code being tested.
This is a nice supplement to the traditional .t files.
How does it work?
Test::Inline lets you write small fragments of general or function-specific testing code, and insert it anywhere you want in your modules, inside a specific tagged POD segment, like the following.
# This code assumes we have a cpuinfo file
ok( -f /proc/cpuinfo, 'Host has a standard /proc/cpuinfo file' );
=begin testing label
# Test generation of the HTML tag
is( My::HTML->label('foo'), '< label >foo< /label >', '->label(simple) works' );
is( My::HTML->label('bar', 'foo'), '< label for="bar" >foo< /label >', '->label(for) works' );
You can add as many, or as few, of these chunks of tests as you wish. The key condition when writing them is that they should be logically independant of each other. Each chunk of testing code should not die or crash if it is run before or after another chunk.
Using inline2test or another test compiler, you can then transform these chunks in a test script, or an entire tree of modules into a complete set of standard Test::More-based test scripts.
These test scripts can then be executed as normal.