NAME
Test::Class::Moose::Report - Test information for Test::Class::Moose
VERSION
version 0.59
SYNOPSIS
my $report = Test::Class::Moose->new->runtests->test_report;
DESCRIPTION
When working with larger test suites, it's useful to have full reporting information available about the test suite. The reporting features of Test::Class::Moose allow you to report on the number of test class instances and methods run (and number of tests), along with timing information to help you track down which tests are running slowly. You can even run tests on your report information:
#!/usr/bin/env perl
use lib 'lib';
use Test::Most;
use Test::Class::Moose::Load qw(t/lib);
my $test_suite = Test::Class::Moose->new;
subtest 'run the test suite' => sub {
$test_suite->runtests;
};
my $report = $test_suite->test_report;
my $duration = $report->time->duration;
diag "Test suite run time: $duration";
foreach my $class ( $report->all_test_instances ) {
my $class_name = $class->name;
ok !$class->is_skipped, "$class_name was not skipped";
subtest "$class_name methods" => sub {
foreach my $method ( $class->all_test_methods ) {
my $method_name = $method->name;
ok !$method->is_skipped, "$method_name was not skipped";
cmp_ok $method->num_tests, '>', 0,
'... and some tests should have been run';
diag "Run time for $method_name: ".$method->time->duration;
}
};
my $time = $class->time;
diag "Run time for $class_name: ".$class->time->duration;
my $real = $time->real;
my $user = $time->user;
my $system = $time->system;
# do with these as you will
}
diag "Number of test instances: " . $report->num_test_instances;
diag "Number of test methods: " . $report->num_test_methods;
diag "Number of tests: " . $report->num_tests;
done_testing;
Reporting is currently in alpha. The interface is not guaranteed to be stable.
The Report
my $report = Test::Class::Moose->new->runtests->test_report;
Or:
my $test_suite = Test::Class::Moose->new;
$test_suite->runtests;
my $report = $test_suite->test_report;
After the test suite is run, you can call the test_report
method to get the report. The test report is a Test::Class::Moose::Report object. This object provides the following methods:
test_instances
Returns an array reference of Test::Class::Moose::Report::Instance instances.
all_test_instances
Returns an array of Test::Class::Moose::Report::Instance instances.
num_test_instances
Integer. The number of test instances run.
num_test_methods
Integer. The number of test methods run.
num_tests_run
Integer. The number of tests run.
time
Returns a Test::Class::Moose::Report::Time object. This object represents the duration of the entire test suite.
Test Report for Instances
Each Test::Class::Moose::Report::Instance instance provides the following methods:
test_methods
Returns an array reference of Test::Class::Moose::Report::Method objects.
all_test_methods
Returns an array of Test::Class::Moose::Report::Method objects.
error
If this class could not be run, returns a string explaining the error.
has_error
Returns a boolean indicating whether or not the class has an error.
name
The name of the test class.
notes
A hashref. The end user may use this to store anything desired.
skipped
If the class or method is skipped, this will return the skip message.
is_skipped
Returns true if the class or method is skipped.
time
Returns a Test::Class::Moose::Report::Time object. This object represents the duration of this class.
Test Report for Methods
Each Test::Class::Moose::Report::Method instance provides the following methods:
name
The "name" of the test method.
notes
A hashref. The end user may use this to store anything desired.
skipped
If the class or method is skipped, this will return the skip message.
is_skipped
Returns true if the class or method is skipped.
time
Returns a Test::Class::Moose::Report::Time object. This object represents the duration of this class or method.
Test Report for Time
Each Test::Class::Moose::Report::Time instance has the following methods:
real
my $real = $time->real;
Returns the "real" amount of time the class or method took to run.
user
my $user = $time->user;
Returns the "user" amount of time the class or method took to run.
system
my $system = $time->system;
Returns the "system" amount of time the class or method took to run.
duration
Returns the returns a human-readable representation of the time this class or method took to run. Something like:
0.00177908 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)
TRUSTED METHODS
The following Test::Class::Moose::Report methods are for internal use only and are called by Test::Class::Moose. They are included here for those who might want to hack on Test::Class::Moose.
_inc_test_methods
$statistics->_inc_test_methods; # increments by 1
$statistics->_inc_test_methods($x); # increments by $x
_inc_tests
$statistics->_inc_tests; # increments by 1
$statistics->_inc_tests($x); # increments by $x
BUGS
Please report any bugs or feature requests to bug-test-class-moose at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Class-Moose. 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::Class::Moose
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
AUTHOR
Curtis "Ovid" Poe <ovid@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Curtis "Ovid" Poe.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.