Test2:...:SRand(3perl)

πŸ’– Test2::...:SRand β€” the manual page, but make it cute πŸ’–

okay bestie, we're looking at Test2:...:SRand(3perl) today, and honestly? it's giving "tiny module, major main character energy." Perl Programmers Reference Guide vibes, let's go πŸ¦‹


✨ NAME ✨

Test2::Plugin::SRand β€” control the random seed so your test environments are way more controlled, periodt πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

So basically this module hands you the aux cord for the random seed your unit tests use. And lowkey that matters, because in some testing environments the random seed can play a major role in your results. like, huge.

The default configuration seeds srand with the local date. and the way that works is kinda iconic: using the date as the seed means that on any given day, the random seed will always be the same. so behavior will not change from run to run on a given day β€” consistent, dependable, no chaos. ✨ but the seed IS different on different days, which lets you be sure the code still works with actual randomness. best of both worlds fr fr 🫢

The seed gets printed for you on failure, or when the harness is verbose. so you're never left guessing. πŸ“’

You can use the T2_RAND_SEED environment variable to specify the seed. you can also provide a specific seed as a load-time argument to the plugin. your choice, your rules πŸ‘‘


🌸 SYNOPSIS 🌸

Loading the plugin is easy, and the defaults are sane:

use Test2::Plugin::SRand;

Custom seed:

use Test2::Plugin::SRand seed => 42;

πŸ’œ NOTE ON LOAD ORDER πŸ’œ

If you use this plugin you probably want to use it as the first, or near-first plugin. not me stressing about order? okay yes me stressing about order 😭

Here's the tea: srand is not called until the plugin is loaded. so other plugins loaded first may already be making use of random numbers before your seed takes effect. don't let them get ahead of you, bestie.


πŸ’€ CAVEATS πŸ’€

When srand is on (default) it can cause problems with things like File::Temp, which will end up attempting the same "random" filenames for every test process started on a given day (or sharing the same seed). yes, the quotes around "random" are doing a lot of heavy lifting there. πŸ™ˆ

⚠️ so like, heads up: same seed + date-based seeding = same filenames = potential collision chaos with File::Temp. noticed and noted.

πŸ”₯ SOURCE πŸ”₯

The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/.


πŸ‘‘ MAINTAINERS πŸ‘‘

Chad Granum <exodist@cpan.org>


⭐ AUTHORS ⭐

Chad Granum <exodist@cpan.org>


Copyright Chad Granum <exodist@cpan.org>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/


and that's the whole page, bestie πŸŽ€ ty for reading, you ate that. this was written against perl v5.44.0 and dated 2026-10-17, and it lives under the name Test2:...:SRand(3perl). mwah πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms