1Config::Model::Tester::USseetrupC(o3n)tributed Perl DocuCmoennftiagt:i:oMnodel::Tester::Setup(3)
2
3
4

NAME

6       Config::Model::Tester::Setup - Common test setup functions for
7       Config::Model
8

VERSION

10       version 4.003
11

SYNOPSIS

13        # in t/some_test.t
14        use warnings;
15        use strict;
16
17        use Config::Model::Tester::Setup qw/init_test setup_test_dir/;
18
19        my ($model, $trace) = init_test();
20
21        # pseudo root where config files are written by config-model as setup
22        # by init_test
23        my $wr_root = setup_test_dir();
24

DESCRIPTION

26       This module provide 2 functions to setup a test environment that can be
27       used in most test involving Config::Model.
28

FUNCTIONS

30   init_test
31       Scan test command line options and initialise a Config::Model object.
32
33       Returns a list containing a Config::Model object, a boolean and a hash.
34       The boolean is true if option "--trace" was used on the command line.
35
36       Default command options are:
37
38       ·   "--error": When set, error handled by Config::Model::Exception
39           shows a strack trace when dying.
40
41       ·   "--log": When set, Log::Log4perl uses the config from file
42           "~/.log4config-model" or the default config provided by
43           Config::Model. By default, only Error level and above are shown.
44           Experimental.
45
46       More options can be passed to "init_test" using option definitions like
47       the one defined in Getopt::Long . The value of the command line options
48       are returned in the 3rd returned value.
49
50       For instance, for a test named "t/my_test.t" calling :
51
52         init_test('foo', 'bar=s')
53
54       The test file can be run with:
55
56         perl t/my_test.t --foo --bar=baz --log --trace
57
58       "init_test" returns:
59
60         ($model, 1, { foo => 1, bar => 'baz', log => 1 , trace => 1, error => 0 })
61
62   setup_test_dir
63       Cleanup and create a test directory in "wr_root/test-script-name". For
64       instance this function creates directory "wr_root/foo" for test
65       "t/foo.t"
66
67       Returns a Path::Tiny object of the test directory or a string if
68       "setup_test_dir" is called with "stringify => 1".
69

SEE ALSO

71       ·   Config::Model
72
73       ·   Test::More
74

AUTHOR

76       Dominique Dumont
77
79       This software is Copyright (c) 2013-2019 by Dominique Dumont.
80
81       This is free software, licensed under:
82
83         The GNU Lesser General Public License, Version 2.1, February 1999
84
85
86
87perl v5.30.0                      2019-07-26   Config::Model::Tester::Setup(3)
Impressum