NAME
Test::Nightly - Run your tests, produce a report on the results.
DESCRIPTION
A customisable interface which will run your tests, and produce a report with the status of the modules in your system.
SYNOPSIS
::: SCENARIO ONE :::
Pass in all the options direct into the constructor.
use Test::Nightly;
my $nightly = Test::Nightly->new({
base_directories => ['/base/dir/from/which/to/search/for/modules/'],
run_tests => {},
generate_report => {
email_report => {
to => 'kirstinbettiol@gmail.com',
},
report_output => '/report/output/dir/test_report.html',
},
email_errors => {
to => 'kirstinbettiol@gmail.com',
},
print_errors => 1,
debug => 1,
});
::: SCENARIO TWO :::
Call each method individually.
use Test::Nightly;
my $nightly = Test::Nightly->new();
$nightly->run_tests();
$nightly->generate_report({
email_report => {
to => 'kirstinbettiol@gmail.com',
},
report_output => '/report/output/dir/test_report.html',
})
The following methods are available:
new()
my $nightly = Test::Nightly->new({
base_directories => \@directories, # Required. Array of base directories to search in.
makefile_names => [Build.PL, Makefile.PL], # Defaults to Makefile.PL.
email_errors => \%email_config, # If set, errors will be emailed.
log_errors => '/path/to/log.txt' # If set, errors will be outputted to the supplied file.
print_errors => 1 # If set, errors will be printed to stdout.
run_tests => {
test_directory_format => ['t/', 'tests/'], # Optional, defaults to 't/'.
test_file_format => ['.t', '.pl'], # Optional, defaults to '.t'.
},
generate_report => {
email_report => \%email_config, # Emails the report. See L<Test::Nightly::Email> for config.
report_template => '/dir/somewhere/template.txt', # Defaults to internal template.
report_output => '/dir/somewhere/output.txt', # File to output the report to.
test_report => 'all', # 'failed' || 'passed'. Defaults to all.
},
});
This is the constructor used to create the main object.
Does a search for all modules on your system, matching the makefile description (L<makefile_names>). You can choose to run all your tests and generate your report directly from this module. Or you can simply supply L<base_directories> and it call the other methods separately. If there are errors with the running of this module then you are able to redirect those errors to your email, a log or to stdout.
run_tests()
$nightly->run_tests({
modules => \@modules, # Optional, default is to use the directories stored in the object.
test_directory_format => ['t/', 'tests/'], # Optional, defaults to ['t/'].
test_file_format => ['.t', '.pl'], # Optional, defaults to ['.t'].
});
Runs all the tests on the directories that are stored in the object.
Results are stored back in the object so they can be reported on.
generate_report()
$nightly->generate_report({
email_report => \%email_config, # Emails the report. See L<Test::Nightly::Email> for config options.
report_template => '/dir/somewhere/template.txt', # Defaults to internal template.
report_output => '/dir/somewhere/output.txt', # File to output the report to.
test_report => 'all', # 'failed' || 'passed'. Defaults to all.
});
Based on the methods that have been run, produces a report on these.
Depending on what you pass in, defines what report is generated. If you pass in an email address to L<email_report> then the report will be
emailed to those people. If you specify an output file to L<report_output> then the report will be outputted to that file.
If you specify both, then both will be done.
Default behavior is to use the internal template that is in L<Test::Nightly::Report::Template>, however you can overwrite this with your own template (L<report_template>). Uses Template Toolkit.
List of methods:
- base_directories
-
Required. Array of base directories to search in.
- debug
-
Turns debugging messages on or off.
- email_errors
-
If on emails any errors generated. Takes a hash ref of \%email_config, refer to Test::Nightly::Email for the options.
- email_report
-
If set will email the report. Takes a hash ref of \%email_config, refer to Test::Nightly::Email for the options.
- errors
-
List of errors that have been generated.
- log_errors
-
If set, will log any errors generated to the file specified.
- makefile_names
-
Searches for the specified makefile names. Defaults to Makefile.PL
- modules
-
List of modules that have been found, returns an array ref of undef.
- print_errors
-
If set, will print the error to stdout.
- report_output
-
Set this to a file somewhere and the report will be outputted here.
- report_template
-
Pass this in if you wish to use your own customised report template. Otherwise uses the default template is in Test::Nightly::Report::Template
- test
-
Holds the Test::Nightly::Test object.
- test_directory_format
-
An array of what format the test directories can be. By default it searches for the tests in 't/'
- test_file_format
-
An array of the test file formats you have.
- test_report
-
This is where you specify what you wish to report on after the outcome of the test. Specifying 'passed' will only report on tests that passed, specifying 'failed' will only report on tests that failed and specifying 'all' will report on both.
TODO
Soon I would like to implement a module that will handle version control, so you are able to checkout and update your modules for testing. As well as this it would be nice to incorporate in a wrapper for Devel::Cover.
Test::Nightly::Version, Test::Nightly::Coverage,
AUTHOR
Kirstin Bettiol <kirstinbettiol@gmail.com>
SEE ALSO
Test::Nightly Test::Nightly::Test Test::Nightly::Report Test::Nightly::Email perl
COPYRIGHT
(c) 2005 Kirstin Bettiol This library is free software, you can use it under the same terms as perl itself.
THANKS
Thanks to Leo Lapworth and Foxtons for letting me develop this on their time.