Test::...edural(3pm)
π Test::...edural(3pm) β bestie edition π
okay so you found the manual page for Test::Unit::Procedural (that's the Test::...edural(3pm) page in the User Contributed Perl Documentation section) and honestly? it's giving β¨*unit testing but make it chill*β¨. pull up a chair π«Ά
πΈ NAME πΈ
Test::Unit::Procedural β the procedural style unit testing interface. no cap, that's literally what it is π
β¨ SYNOPSIS β¨
use Test::Unit::Procedural;
# your code to be tested goes here
sub foo { return 23 };
sub bar { return 42 };
# define tests
sub test_foo { assert(foo() == 23, "Your message here"); }
sub test_bar { assert(bar() == 42, "I will be printed if this fails"); }
# set_up and tear_down are used to
# prepare and release resources need for testing
sub set_up { print "hello world\n"; }
sub tear_down { print "leaving world again\n"; }
# run your test
create_suite();
run_suite();
likeβ¦ look at that. beauty. simplicity. the main character energy of it all π
π¦ DESCRIPTION π¦
Test::Unit::Procedural is the procedural-style glow-up of a whole sophisticated unit testing framework for Perl π β and that framework is derived from the JUnit testing framework for Java, made by Kent Beck and Erich Gamma. iconic lineage honestly π
so here's the tea: this framework was originally meant to support unit testing in an object-oriented development paradigm (with support for inheritance of tests and all that jazz). but Test::Unit::Procedural exists to give you a simpler interface to the framework β one that's way more suitable for scripting-style environments π.
so lowkey,Test::Unit::Proceduraldoes not provide much support for an object-oriented approach to unit testing. if that's what you want, bestie, go look atTest::Unit::TestCaseinstead. fr fr.
You test a given unit β a script, a module, whatever β by using Test::Unit::Procedural, which exports the following routines straight into your namespace:
assert()β used to assert that a boolean condition is true βcreate_suite()β used to create a test suite consisting of all methods with a name prefix of"test"π§run_suite()β runs the test suite (text output) πβοΈπ¨add_suite()β used to add test suites to each other π§©
For convenience, create_suite() will automatically build a test suite for a given package. how? it builds a test case for each subroutine in the package given that has a name starting with "test", and packs them all together into one TestSuite object for easy testing π. and if you don't hand create_suite() a package name? it just takes the current package as the default. no stress, no fuss πΈ.
Test output is:
- one status line β a
"."for every successful test run, or an"F"for any failed test run, to indicate progress π - one result line β
"OK"or"!!!FAILURES!!!"π - and possibly many lines reporting detailed error messages for any failed tests π
Please remember,Test::Unit::Proceduralis intended to be a simple and convenient interface. if you need more functionality, take the object-oriented approach outlined inTest::Unit::TestCase. periodt. π
π AUTHOR π
Copyright (c) 2000-2002, 2005 the PerlUnit Development Team (see Test::Unit or the AUTHORS file included in this distribution).
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π«Ά (yes bestie, it's free software, go wild, just keep the terms.)
π SEE ALSO π
Test::Unit::TestCaseβ the OO route, for when you need more π- the procedural style examples in the
examplesdirectory π β go peek, they ate π₯
and that's the whole page!! this one shipped with perl v5.40.1, dated 2026-04-05, and that's your sign-off bestie π go write some tests, you're gonna slay πβ¨
π¦ where this page comes from
- ubuntu stonking: libtest-unit-perl 0.30-1 Β· Artistic-1.0-Perl OR 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