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::Procedural does not provide much support for an object-oriented approach to unit testing. if that's what you want, bestie, go look at Test::Unit::TestCase instead. 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::Procedural is intended to be a simple and convenient interface. if you need more functionality, take the object-oriented approach outlined in Test::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 examples directory πŸ“‚ β€” 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