FunctionalTestCase(3pm)

πŸ“¦ version 2.1.1, in arch rolling

πŸ’– FunctionalTestCase(3pm) πŸ’–

okay so this is from LogReport's Lire Documentation, and it's literally the manual page for FunctionalTestCase(3pm) β€” the Perl class bestie for writing functional tests. 🫢


πŸ’– NAME πŸ’–

Lire::Test::FunctionalTestCase β€” base class for writing functional unit tests, periodt.


✨ SYNOPSIS ✨

use base qw/ Lire::Test::FunctionalTestCase/;

🌸 DESCRIPTION 🌸

This is a Test::Unit::TestCase subclass, and its whole job is making functional tests easier to write. No cap.

🧚 WHAT ARE FUNCTIONAL TESTS 🧚

Unit tests test the semantics of the API and document the internal assumptions. Functional tests are different: they test the functionality of the overall software. They kind of document the expected functionality of the software. It's giving "big picture behavior" energy. πŸ’…

πŸ‘‘ Lire::Test::FunctionalTestCase πŸ‘‘

In Lire, that "expected functionality" gets exercised by running commands, so this module gives you convenient methods to run Lire commands and test their expected output.

It also sets up a mock sendmail, which you can use to analyze the email that the Lire system should send. πŸ“¬

Some Lire functionality can't be tested anymore just by running a command β€” for example, the Curses::UI based user interface can't be tested that way, but it can be tested through the use of Lire::Test::CursesUIDriver. For these kinds of tests, this base class will set up a new Lire::Config and Lire::PluginManager instance in the set_up method. Tests that require this functionality can simply call Lire::Config->init() and Lire::PluginManager->instance()->register_default_converters() without fear of messing up the test environment. πŸ›Ÿ


🏠 homedir()

Returns the directory which will be assigned to ENV{'HOME'} when commands are run. This directory is cleaned up after every test.

πŸ“‚ rundir()

Returns the directory which will be the working directory when the commands are run. This directory is cleaned up after every test.

🧩 config_spec()

Returns the Lire::Config::TypeSpec object which will be used at runtime by the functional tests. It can be used to set up configuration files for the test.

🌍 locale( [new_locale] )

Changes the locale under which the functional test is going to be run. By default, all tests are run under the 'C' locale, ignoring all user's environment variables.

Returns the previous locale set.

πŸƒ lire_run( $shell_cmd )

This method runs the command $shell_cmd through the shell and returns a Lire::Test::CommandResult object which can be used to run tests on this command. The Lire environment will be set up before invoking the shell.

πŸ“¨ sent_mail()

Returns in an array reference the messages that were sent out during the test. Each element of this array is a hash reference containing two keys:

  • recipients β€” an array reference containing the recipients as passed on the command line to sendmail.
  • message β€” the email which was sent. This is the complete text of the email. This is what was passed to sendmail via STDIN.

πŸ“ create_test_file( $filename, [$content] )

Create a file $filename with the content $content. This file will be removed after the test is run during the tear_down() method. An empty file will be created if the $content parameter is omitted.

πŸ§ͺ install_xml_spec( $spec_type, $superservice, $file )

Install the XML specification in $file of base schema $superservice. The $spec_type parameter specifies where the file will be installed:

  • site_filter β€” the file will be installed as a filter specification in the system directory.
  • site_report β€” the file will be installed as a report specification in the system directory.
  • site_schema β€” the file will be installed as a schema specification in the system directory.
  • filter β€” the file will be installed as a filter specification in the HOME directory.
  • report β€” the file will be installed as a report specification in the HOME directory.
  • schema β€” the file will be installed as a schema specification in the HOME directory.

These files will be removed after the test.

βš™οΈ create_test_cfg_file( $name )

Returns a Lire::Config::ConfigFile object initialized with the appropriate config specification. This configuration file will be created under $HOME/.lire/config/$name.xml when lire_run() will be used. It can be used to set config options which will be used when the command is run:

my $cfg = $self->create_test_cfg_file( "test" );
$cfg->global->get( "lr_from" )->set( "flacoste\@logreport.org" );

If a configuration file $name was already created, it returns the associated ConfigFile object.

Note bestie: if you want these configuration variables to have effect when running a test in-process (not via lire_run()), you have to call save() on the object before calling Lire::Config->init(). Otherwise, you better set the configuration option directly using the Lire::Config API. πŸ’…

🌈 SEE ALSO 🌈

Test::Unit::TestCase(3pm)


πŸŽ€ VERSION πŸŽ€

$Id: FunctionalTestCase.pm,v 1.27 2006/07/23 13:16:31 vanbaal Exp $

πŸ‘‘ AUTHOR πŸ‘‘

Francis J. Lacoste <flacoste@logreport.org>


Copyright (C) 2003 Stichting LogReport Foundation LogReport@LogReport.org

This file is part of Lire.

Lire is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html.


okay so this page was FunctionalTestCase(3pm) from Lire 2.1.1, dated 2025-09-28. That's the whole vibe check, bestie β€” go write some iconic functional tests! πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from