1Test2::Plugin::SRand(3)User Contributed Perl DocumentatioTnest2::Plugin::SRand(3)
2
3
4
6 Test2::Plugin::SRand - Control the random seed for more controlled test
7 environments.
8
10 This module gives you control over the random seed used for your unit
11 tests. In some testing environments the random seed can play a major
12 role in results.
13
14 The default configuration for this module will seed srand with the
15 local date. Using the date as the seed means that on any given day the
16 random seed will always be the same, this means behavior will not
17 change from run to run on a given day. However the seed is different on
18 different days allowing you to be sure the code still works with actual
19 randomness.
20
21 The seed is printed for you on failure, or when the harness is verbose.
22 You can use the "T2_RAND_SEED" environment variable to specify the
23 seed. You can also provide a specific seed as a load-time argument to
24 the plugin.
25
27 Loading the plugin is easy, and the defaults are sane:
28
29 use Test2::Plugin::SRand;
30
31 Custom seed:
32
33 use Test2::Plugin::SRand seed => 42;
34
36 If you use this plugin you probably want to use it as the first, or
37 near-first plugin. "srand" is not called until the plugin is loaded, so
38 other plugins loaded first may already be making use of random numbers
39 before your seed takes effect.
40
42 The source code repository for Test2-Suite can be found at
43 https://github.com/Test-More/Test2-Suite/.
44
46 Chad Granum <exodist@cpan.org>
47
49 Chad Granum <exodist@cpan.org>
50
52 Copyright 2018 Chad Granum <exodist@cpan.org>.
53
54 This program is free software; you can redistribute it and/or modify it
55 under the same terms as Perl itself.
56
57 See http://dev.perl.org/licenses/
58
59
60
61perl v5.38.0 2023-07-21 Test2::Plugin::SRand(3)