Test2:...Module(3perl)

πŸ’– Test2::Require::Module β€” from the Perl Programmers Reference Guide, bestie ✨

Okay so this is a page from the Perl Programmers Reference Guide, manual section 3perl, and the module it's teaching you about is literally called Test2:...Module up top but the real name is Test2::Require::Module. Same thing, promise. 🫢


✨ NAME ✨

Test2::Require::Module β€” skip tests if certain packages are not installed, or insufficient versions. πŸ’…


🌸 DESCRIPTION 🌸

So here's the vibe: sometimes you've got tests that are nice to run, but they depend on tools that might not be there. 😭

Instead of making the tool a dep, or making the test always skip, the normal move is to make the test run conditionally. That's literally what this package is here for. πŸ‘‘

This module is modeled after Test::Requires. The glow-up differences are:

  • It's based on Test2 directly, and does not go through Test::Builder. no cap.
  • The packages you check for do not get imported into your namespace for you. And that is intentional, bestie. it's giving boundaries. πŸŽ€

πŸ¦‹ SYNOPSIS πŸ¦‹

# The test will be skipped unless Some::Module is installed, any version.
use Test2::Require::Module 'Some::Module';

# The test will be skipped unless 'Other::Module' is installed and at
# version '5.555' or greater.
use Test2::Require::Module 'Other::Module' => '5.555';

# We now need to use them directly, Test2::Require::Module does not import
# them for us.
use Some::Module;
use Other::Module;

See that last bit? You gotta use them yourself. It does not do it for you. periodt. πŸ’…


⭐ SOURCE ⭐

The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/. go stare at it, it's iconic. πŸ”₯


πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org> β€” the main character fr fr πŸ’œ

🌈 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/ 🧚


lowkey important: this one's from perl v5.44.0, dated 2026-10-17. that's the whole page, babes β€” go write some conditional tests, you ate. πŸ’–βœ¨πŸŽ€
πŸ“¦ 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