NAME
Test::Instruction - A test framework
VERSION
Version 0.02
SYNOPSIS
use Test::Instruction qw/all/;
use Module::To::Test;
instruction(
test => 'true',
func => \&Module::To::Test::true_function
);
instruction(
test => 'false',
func => \&Module::To::Test::false_function
);
my $obj = Module::To::Test->new();
instruction(
test => 'hash',
instance => $obj,
meth => 'method_that_returns_a_hash',
expected => { a => 1, b => 2, c => 3 }
);
finish(3);
...
use Test::Instruction qw/all/;
instructions(
name => 'Checking Many Things',
debug => 1,
build => {
class => 'London',
},
run => [
{
test => 'hash',
expected => {
booking => '66/68',
}
},
{
test => 'true',
meth => 'true',
},
{
test => 'false',
meth => 'false',
},
{
test => 'ok',
meth => "chain",
instructions => [
{
test => 'hash',
expected => {
paddington => "sleep"
}
}
]
}
],
);
finish();
EXPORT
instruction
instruction(
test => 'ok',
instance => Module::To::Test->new(),
func => 'okay',
args => {
data => '...'
},
);
test
you can currently run the following tests.
over
- ok - ok - a true value
- ref - is_deeply - expected [] or {}
- scalar - is - expected '',
- hash - is_deeply - expected {},
- array - is_deeply - expected [],
- obj - isa_ok - expected '',
- like - like - '',
- true - is - 1,
- false - is - 0,
- undef - is - undef
- ref_key_scalar - is - '' (requires key)
- ref_key_ref - is_deeply - [] or {} (requires key)
- ref_key_like - like - ''
- ref_index_scalar - is - '' (requires index)
- ref_index_ref - is_deeply - [] or {} (required index)
- ref_index_like - like - ''
- ref_index_obj - isa_ok - ''
- list_key_scalar - is - '' (requires key)
- list_key_ref - is_deeply - [] or {} (requires key)
- list_key_like - like - ''
- list_index_scalar - is - '' (requires index)
- list_index_ref - is_deeply - [] or {} (required index)
- list_index_obj - isa_ok - ''
- list_index_like - like - ''
- count - is - ''
- count_ref - is - ''
- skip - ok(1)
- code - is - 'CODE'
- code_execute - is_deeply - ''
catch
when you want to catch exceptions....
catch => 1,
defaults the instruction{test} to like.
instance
my $instance = My::Test::Module->new();
instance => $instance,
meth
call a method from the instance
instance => $instance,
meth => 'render'
func
func => \&My::Test::Module::render,
ref_key
instance => { a => 1 },
ref_key => 'a'
ref_index
instance => [ 1, 2, 3 ],
ref_index => 2
args
{} or []
args_list
args => [qw/one, two/],
args_list => 1,
index
index - required when testing - ref_index_* and list_index_*
key
key - required when testing - ref_key_* and list_key_*
instructions
package Foo;
sub new { bless {}, shift; }
sub bar { ['a', [1, 2, 3], 'b'] }
1;
instructions(
name => 'Testing Foo',
build => {
class => 'Foo',
},
run => [
{
test => 'ok',
meth => 'bar',
instructions => [
{
test => 'ref_index_scalar',
index => 0,
expected => 'a'
},
{
test => 'ok',
ref_index => 1,
instructions => [
{
test => 'array',
expected => [1, 2, 3]
},
{
test => 'ref_index_scalar',
index => 0,
expected => 1
}
]
},
...
]
}
]
);
finish
finish();
finish($total_number_of_tests);
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-test-instruction at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Instruction. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Test::Instruction
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2022 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 618:
'=item' outside of any '=over'