1Config::Model::Tester::USseetrupC(o3nptmr)ibuted Perl DoCcounmfeingt:a:tMioodnel::Tester::Setup(3pm)
2
3
4

NAME

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

VERSION

10       version 4.007
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           Note that log tests are disabled when this option is set, so you
45           may see a lot of harmless Warning messages during tests (which
46           depend on the tests to be run).  Experimental.
47
48       More options can be passed to "init_test" using option definitions like
49       the one defined in Getopt::Long . The value of the command line options
50       are returned in the 3rd returned value.
51
52       For instance, for a test named "t/my_test.t" calling :
53
54         init_test('foo', 'bar=s')
55
56       The test file can be run with:
57
58         perl t/my_test.t --foo --bar=baz --log --trace
59
60       "init_test" returns:
61
62         ($model, 1, { foo => 1, bar => 'baz', log => 1 , trace => 1, error => 0 })
63
64   setup_test_dir
65       Cleanup and create a test directory in "wr_root/test-script-name". For
66       instance this function creates directory "wr_root/foo" for test
67       "t/foo.t"
68
69       Returns a Path::Tiny object of the test directory or a string if
70       "setup_test_dir" is called with "stringify => 1".
71

SEE ALSO

73       •   Config::Model
74
75       •   Test::More
76

AUTHOR

78       Dominique Dumont
79
81       This software is Copyright (c) 2013-2020 by Dominique Dumont.
82
83       This is free software, licensed under:
84
85         The GNU Lesser General Public License, Version 2.1, February 1999
86
87
88
89perl v5.38.0                      2023-07-20 Config::Model::Tester::Setup(3pm)
Impressum