Test::Roo::Class(3pm)
β¨ Test::Roo::Class β¨
okay bestie, so this is a Test::Roo::Class page from the Perl docs β user contributed, very demure, very mindful π
β and I'm about to make it make sense.
π NAME π
Test::Roo::Class β it's the base class for Test::Roo test classes. that's the whole vibe. π¦
π VERSION π
version 1.004 β she's on 1.004, no cap.
πΈ DESCRIPTION πΈ
So basically? This module is the base class for Test::Roo test classes. She's the mother of the whole little family. π
What she brings to the table: methods to run tests, and methods that act as anchors for modifiers. that's her job. that's her whole thing.
π«Ά Important bestie note: generally, you should not extend this class yourself. like, don't do it. use Test::Roo to do that for you instead. she's the scaffolding, not the house, iykyk.
π§ ATTRIBUTES π§
π description
A description for a subtest block that wraps all the tests run by the object. she's a 'lazy' attribute β she shows up when she's needed, main character energy, no rushing her. β¨
Test classes are allowed to implement their own _build_description method to cook up a description from the object's attributes. and if they don't? the default is "testing with CLASS". that's the fallback, periodt.
π METHODS π
β run_tests
# as a class method
$class->run_tests();
$class->run_tests($description);
$class->run_tests($init_args);
$class->run_tests($description $init_args);
# as an object method
$self->run_tests();
$self->run_tests($description);
Here's the tea: π
- If you call it as a class method, it creates a test object for you, using an optional hash reference of initialization arguments. (optional!! she's flexible like that.)
- If you call it as an object method β or, honestly, any time after an object has already been generated β this method sets an optional description and then runs the tests.
and when she runs the tests, she does the full routine, in order, no skipping steps:
- She calls the
"setup"method β which triggers any method modifiers. - She runs all the tests β which triggers any method modifiers on
"each_test". - She calls the
"teardown"method β which also triggers any method modifiers.
If a description is provided, it will override any initialized or generated "description" attribute. like, no discussion, the argument wins. π
π The setup, the tests, and the teardown all get executed inside a Test::More subtest block. so it's all tidy and wrapped up cute.
πΌ setup
This is an empty method used to anchor method modifiers. That's literally her whole purpose in life, and honestly? valid.
π« It should not be overridden by subclasses. don't do it. she's load-bearing.
π¦ each_test
This method wraps the code references set by the "test" function from Test::Roo or Test::Roo::Role in a Test::More subtest block. so every test gets its own little subtest moment. β¨
It may also be used to anchor modifiers that should run before or after each test block. but β and this is the caveat, bestie, listen β that can lead to a brittle design, because modifiers will globally affect every test block, including composed ones. like, all of them. every single one. no exceptions. π so maybe think twice before you go wild in there.
π teardown
This is an empty method used to anchor method modifiers. same deal as setup, different end of the test lifecycle. π
π« It should not be overridden by subclasses either. fr fr, don't.
π AUTHOR π
David Golden <dagolden@cpan.org> β the icon who made this happen. π«Ά
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2013 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
slay, honestly. π₯
and that's the page!! π this was Test::Roo::Class(3pm) for perl v5.34.0, dated 2022-06-28. mwah, go write some tests bestie ππ
π¦ where this page comes from
- debian bookworm: libtest-roo-perl 1.004-2 Β· Apache-2.0
- debian trixie: libtest-roo-perl 1.004-2 Β· Apache-2.0
- ubuntu noble: libtest-roo-perl 1.004-2 Β· Apache-2.0
- ubuntu resolute: libtest-roo-perl 1.004-2 Β· Apache-2.0
- ubuntu stonking: libtest-roo-perl 1.004-2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms