Test::Stream::Plugin::Core - Test::Stream implementation of the core Test::More tools.
This is an experimental release! Test-Stream, and all its components are still in an experimental phase. This dist has been released to cpan in order to allow testers and early adopters the chance to write experimental new tools with it, or to add experimental support for it into old tools.
PLEASE DO NOT COMPLETELY CONVERT OLD TOOLS YET. This experimental release is very likely to see a lot of code churn. API's may break at any time. Test-Stream should NOT be depended on by any toolchain level tools until the experimental phase is over.
This is not a drop-in replacement for Test::More.
The new Testing library to replace Test::More. This library is directly built on new internals instead of Test::Builder.
This module implements most of the same functionality as Test::More, but since changing to this library from Test::More is not automatic, some incompatible API changes have been made. If you decide to replace Test::More in existing test files, you may have to update some function calls.
use Test::Stream qw/Core/; set_encoding('utf8'); plan($num); # Optional, set a plan use Data::Dumper; imported_ok qw/Dumper/; not_imported_ok qw/dumper/; # skip all tests in some condition skip_all("do not run") if $cond; if ($passing) { pass('a passing test'); } else { fail('a failing test'); } ok($x, "simple test"); # Check that the class or object has the specified methods defined. can_ok($class_or_obj, @methods); # Check that the class or object is or subclasses the specified packages isa_ok($class_or_obj, @packages); # Check that the class or object consumes the specified roles. DOES_ok($class_or_obj, @roles); # Check that $ref is a HASH reference ref_ok($ref, 'HASH', 'Must be a hash') # The preferred way to plan done_testing;
All subs are exported by default.
Simple assertion. If $bool is true the test passes, if it is false the test fails. The test name is optional, and all arguments after the name are added as diagnostics message if and only if the test fails. If the test passes all the diagnostics arguments will be ignored.
$bool
Fire off a passing test (a single Ok event). The name is optional
Fire off a failing test (a single Ok event). The name and diagnostics are optional.
Check that the specified subs have been defined in the current namespace. This will NOT find inherited subs, the subs must be in the current namespace.
Check that the specified subs have NOT been defined in the current namespace. This will NOT find inherited subs, the subs must be in the current namespace.
This checks that $thing (either a class name, or a blessed instance) has the specified methods.
$thing
This checks that $thing (either a class name, or a blessed instance) is or subclasses the specified classes.
This checks that $thing (either a class name, or a blessed instance) does the specified roles.
This checks that $thing is a reference. If $type is specified then it will check that $thing is that type of reference.
$type
Verify that 2 references are the exact same reference.
Verify that 2 references are not the exact same reference.
Write diagnostics messages. All items in @messages will be joined into a single string with no seperator. When using TAP diagnostics are sent to STDERR.
@messages
Write note-diagnostics messages. All items in @messages will be joined into a single string with no seperator. When using TAP note-diagnostics are sent to STDOUT.
Set the number of tests that are expected. This must be done first or last, never in the middle of testing.
Set the plan to 0 with a reason, then exit true. This should be used before any tests are run.
Used to mark the end of testing. This is a safe way to have a dynamic or unknown number of tests.
Something has gone horribly wrong, stop everything, kill all threads and processes, end the process with a false exit status.
This is used to mark some results as TODO. TODO means that the test may fail, but will not cause the overall test suite to fail.
There are 2 ways to use this, the first is to use a codeblock, the TODO will only apply to the codeblock.
ok(1, "before"); # Not TODO todo 'this will fail' => sub { # This is TODO, as is any other test in this block. ok(0, "blah"); }; ok(1, "after"); # Not TODO
The other way is to use a scoped variable, TODO will end when the variable is destroyed or set to undef.
ok(1, "before"); # Not TODO { my $todo = todo 'this will fail'; # This is TODO, as is any other test in this block. ok(0, "blah"); }; ok(1, "after"); # Not TODO
This is the same thing, but without the {...} scope.
{...}
ok(1, "before"); # Not TODO my $todo = todo 'this will fail'; ok(0, "blah"); # TODO $todo = undef; ok(1, "after"); # Not TODO
This is used to skip some tests. This requires you to wrap your tests in a block labeled SKIP:, this is somewhat magical. If no $count is specified then it will issue a single result. If you specify $count it will issue that many results.
SKIP:
$count
SKIP: { skip "This will wipe your drive"; # This never gets run: ok(!system('sudo rm -rf /'), "Wipe drive"); }
This will set the encoding to whatever you specify. This will only effect the output of the current formatter, which is usually your TAP output formatter.
Subtest support
Tools for intercepting events, exceptions, warnings, etc.
Tools for testing your test tools
Use this module directly for more control over concurrency.
The source code repository for Test::Stream can be found at http://github.com/Test-More/Test-Stream/.
Copyright 2015 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
To install Test::Stream, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Stream
CPAN shell
perl -MCPAN -e shell install Test::Stream
For more information on module installation, please visit the detailed CPAN module installation guide.