Test::Stream::Context - Object to represent a testing context.
In testing it is important to have context. It is not helpful to simply say a test failed, you want to know where it failed. This object is responsible for tracking the context of each test that is run. It makes it possible to get the file and line number where the failure occured .This object is also responsible for generating almost all the events you will encounter.
use Test::Stream::Context qw/context/; sub my_tool { my $ctx = context(); # Generate an event. $ctx->ok(1, "Pass!"); } 1;
This function is used to obtain a context. If there is already a context object in scope this will return it, otherwise it will return a new one.
It is important that you never store a context object in a variable from a higher scope, a package variable, or an object attribute. The scope of a context matters a lot.
If you want to store a context for later reference use the snapshot() method to get a clone of it that is safe to store anywhere.
snapshot()
This issues a warning at the calling context (filename and line number where errors should be reported).
This throws an exception at the calling context (filename and line number where errors should be reported).
Get the caller details for the context. This is where errors should be reported.
Get the context package.
Get the context filename.
Get the context line number.
Get the context subroutine name.
Get a copy of the context object that is safe to store for later reference.
Send an event to the correct Test::Stream object.
Get the current context object, if there is one.
Set the context object as the current one, replacing any that might already be current.
Unset the current context.
Register a new event type, creating the shortcut method to generate it. If $name is not provided it will be taken from the end of the package name, and will be lowercased.
$name
Get the hashref that holds (name => $package) pairs. This is the actual ref used by the package, so please do not alter it.
(name => $package)
These are used to temporarily hide the TODO value in ALL places where it might be found. The returned $stash must be used to restore it later.
$stash
The source code repository for Test::More can be found at http://github.com/Test-More/test-more/.
The following people have all contributed to the Test-More dist (sorted using VIM's sort function).
There has been a lot of code migration between modules, here are all the original copyrights together:
Copyright 2014 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
Originally authored by Michael G Schwern <schwern@pobox.com> with much inspiration from Joshua Pritikin's Test module and lots of help from Barrie Slaymaker, Tony Bowden, blackstar.co.uk, chromatic, Fergal Daly and the perl-qa gang.
Idea by Tony Bowden and Paul Johnson, code by Michael G Schwern <schwern@pobox.com>, wardrobe by Calvin Klein.
Copyright 2001-2008 by Michael G Schwern <schwern@pobox.com>.
To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Test-use-ok.
This work is published from Taiwan.
http://creativecommons.org/publicdomain/zero/1.0
This module is copyright 2005 Fergal Daly <fergal@esatclear.ie>, some parts are based on other people's work.
Under the same license as Perl itself
Copyright Mark Fowler <mark@twoshortplanks.com> 2002, 2004.
To install Test::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Simple
CPAN shell
perl -MCPAN -e shell install Test::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.