Config::Model::Tester::Setup - Common test setup functions for Config::Model
version 3.006
# in t/some_test.t use warnings; use strict; use Config::Model::Tester::Setup qw/init_test setup_test_dir/; my ($model, $trace) = init_test(); # pseudo root where config files are written by config-model as setup # by init_test my $wr_root = setup_test_dir();
This module provide 2 functions to setup a test environment that can be used in most test involving Config::Model.
Scan test command line options and initialise a Config::Model object.
Returns a list containing a Config::Model object, a boolean and a hash. The boolean is true if option --trace was used on the command line.
--trace
Default command options are:
--error: When set, error handled by Config::Model::Exception shows a strack trace when dying.
--error
--log: When set, Log::Log4perl uses the config from file ~/.log4config-model or the default config provided by Config::Model. Without 'l', only Error level and above are shown. Experimental.
--log
~/.log4config-model
More options can be passed to init_test using option definitions like the one defined in Getopt::Long . The value of the command line options are returned in the 3rd returned value.
init_test
For instance, for a test named t/my_test.t calling :
t/my_test.t
init_test('foo', 'bar=s')
The test file can be run with:
perl t/my_test.t --foo --bar=baz --log --trace
init_test returns:
($model, 1, { foo => 1, bar => 'baz', log => 1 , trace => 1, error => 0 })
Cleanup and create a test directory in wr_root/test-script-name. For instance this function creates directory wr_root/foo for test t/foo.t
wr_root/test-script-name
wr_root/foo
t/foo.t
Returns a Path::Tiny object of the test directory or a string if setup_test_dir is called with stringify => 1.
setup_test_dir
stringify => 1
Config::Model
Test::More
Dominique Dumont
This software is Copyright (c) 2013-2018 by Dominique Dumont.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999
To install Config::Model::Tester, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Model::Tester
CPAN shell
perl -MCPAN -e shell install Config::Model::Tester
For more information on module installation, please visit the detailed CPAN module installation guide.