Test::FITesque(3pm)

πŸ“¦
version 0.04 Β· 2 versions
  • 0.04 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.04 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Test::FITesque β€” the FITesque framework! πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation section, and honestly? it's giving framework energy. sit down, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

Test::FITesque β€” the FITesque framework! πŸ’…


✨ VERSION ✨

Version 0.04 β€” yeah she's been around a minute, and she's still iconic πŸ‘‘


✨ DESCRIPTION ✨

So Test::FITesque is a framework that's out here emulating the FIT framework (http://fit.c2.com), but with a way more perlish touch. Like, sure, you could use the FIT framework from inside perl, but ngl it comes with a whole lot of unnecessary overhead because of its origins in the Java world 😭 no shade, just facts.

I (the author, hi 🫢) created Test::FITesque for these reasons:

  • I wanted to store my fixture tables in whatever format I wanted (JSON, YAML, Storable, etc) β€” your table, your rules, periodt.
  • I wanted to simplify the execution process so it's very transparent. I'd been using FitNesse up to this point along with the perl server, but the java framework was painful to debug and overly complex for the task it needed to achieve πŸ’€.
  • I wanted to use the normal perl testing tools and utilities so it'd fit my workflow more closely 🧚
  • I also wanted to be able to save the TAP output, so I could more easily capture test results over time and track regressions and problematic tests πŸ“ˆ

🌸 INTRODUCTION 🌸

FITesque starts with creating FITesque fixtures, which are simply packages that let you create objects, and then call methods on those objects. iconic behavior, honestly.

package MyApp::Test::Fixture;

use strict;
use warnings;
use base qw(Test::FITesque::Fixture);
use Test::More;

file_exists : Test {
  my ($self, $file) = @_;

  ok -e $file, qq{File '$file' exists};
}

This simple fixture can now be run with a very basic and simple test ✨

my $test = Test::FITesque::Test->new({
  data => [
    ['MyApp::Test::Fixture'],
    ['file_exists', '/etc/hosts']
  ]
});
$test->run_tests();

The data option is just a table of data to use when executing the fixture test. The first row must refer to the name of the Test::FITesque::Fixture-based fixture you wish to execute (like MyApp::Test::Fixture up there πŸ‘†). Any other cells in this row get passed to the new() method on the Fixture class.

The rows after that? Those are all method calls on an instance of the Fixture class. The first cell must refer to a method name in the Fixture class, and all the following cells get passed to the methods as arguments.

The run_tests() method on the FITesque test will simply run these methods in the order specified, while taking care of maintaining TAP test count and the like underneath. she handles the boring stuff so you don't have to πŸ’…

If you've got more than one instance of a test to run, you can add it to a suite:

my $suite = Test::FITesque::Suite->new({
  data => [$test1, $test2, $test3]
});
$suite->run_tests();

This also lets you run test fixtures in a more dynamic fashion, while still taking care of TAP test count. multitasking queen πŸ‘‘

Suites can not only take a list of tests to run β€” they can take suites themselves. it's suites all the way down, bestie πŸ¦‹

The Test::FITesque package also supplies some handy helper functions to wrap most of the logic up for you. Peep the SYNOPSIS below for more info πŸ‘€


⭐ SYNOPSIS ⭐

use Test::FITesque;

run_tests {
  suite { ... },
  test {
    ['MyApp::Test::Fixture'],
    ['file_exists', '/etc/hosts']
  }
};

πŸ’… EXPORTED FUNCTIONS πŸ’…

πŸŽ€ test

test {
  ['Fixture::Class'],
  ['divides',    qw(8 4 2)],
  ['multiplies', qw(5 6 30)],
  ['adds',       qw(4 3 7)],
}

This function returns a Test::FITesque::Test object. It takes a coderef which returns a list of array references β€” and the first one must refer to your FITesque fixture. no exceptions, that's the rule πŸ“

πŸŽ€ suite

suite {
  test {
    ...
  },
  test {
    ...
  },
  suite {
    test {
      ...
    }
  },
}

This function returns a Test::FITesque::Suite object. It takes a coderef which returns a list of Test::FITesque::Test objects and/or Test::FITesque::Suite objects. mix and match, go off 🌈

πŸŽ€ run_tests

run_tests {
  suite {
    ...
  },
  test {
    ...
  }
}

This function takes a coderef of suite and/or test objects. It'll then wrap these all into a suite and call Test::FITesque::Suite's run_tests method. one call to rule them all, iykyk πŸ’–


πŸ¦‹ SEE ALSO πŸ¦‹

Test::FITesque::Fixture, Test::FITesque::Test, Test::FITesque::Suite


πŸ”₯ TEST COVERAGE πŸ”₯

This distribution is heavily unit and system tested for compatibility with Test::Builder. If you come across any bugs, please send me or submit failing tests to Test-FITesques RT queue. Please see the 'SUPPORT' section below on how to supply these. we love a thorough queen 🫢

 ---------------------------- ------ ------ ------ ------ ------ ------ ------
 File                           stmt   bran   cond    sub    pod   time  total
 ---------------------------- ------ ------ ------ ------ ------ ------ ------
 blib/lib/Test/FITesque.pm     100.0  100.0    n/a  100.0  100.0    5.2  100.0
 .../Test/FITesque/Fixture.pm  100.0  100.0  100.0  100.0  100.0   29.1  100.0
 ...ib/Test/FITesque/Suite.pm  100.0  100.0  100.0  100.0  100.0   14.6  100.0
 ...lib/Test/FITesque/Test.pm  100.0  100.0  100.0  100.0  100.0   51.1  100.0
 Total                         100.0  100.0  100.0  100.0  100.0  100.0  100.0
 ---------------------------- ------ ------ ------ ------ ------ ------ ------

look at those numbers. 100.0 across the board?? she ATE and left no crumbs πŸ’€βœ¨


πŸ‘‘ AUTHOR πŸ‘‘

Scott McWhirter, "<konobi at cpan.org>" β€” legend behavior 🫑


πŸ’œ TODO πŸ’œ

  • Add more documentation
  • Add some cookbook examples
  • Look at some of the Fixture base class code to see if it can be restructured to allow for more evil coderef support 😈
  • Update code to take advantage of newer Test::Harness/Test::Builder features

(the "more evil coderef support" line lives in my head rent free fr fr)


πŸ™ˆ BUGS πŸ™ˆ

Please report any bugs or feature requests to "bug-test-fitesque at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-FITesque. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. we love a feedback loop πŸ’–


πŸ’€ LIMITATIONS πŸ’€

Due to limitations in the TAP protocol and perl's TAP tools such as Test::Harness, all Fixture tables have to be held in memory.

It also means Fixture tables can't be treated as a stream, so there's no easy way to separate out which tables' output is which 😭. To remedy this, I suggest you pass a 'name' parameter to the Fixture class's constructor and print this to screen, or use the diag() function from Test::More. lowkey a hack but it works πŸŽ€


🧚 SUPPORT 🧚

You can find documentation for this module with the perldoc command.

perldoc Test::FITesque

You can also look for information at:

  • AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Test-FITesque

  • CPAN Ratings

http://cpanratings.perl.org/d/Test-FITesque

  • RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-FITesque

  • Search CPAN

http://search.cpan.org/dist/Test-FITesque


Copyright 2007 Scott McWhirter, all rights reserved.

This program is released under the following license: BSD. Please see the LICENSE file included in this distribution for details.


and that's the whole page bestie πŸ’– this one's running under perl v5.34.0, dated 2022-07-04 β€” she's a classic, and she's still serving. mwah πŸ’…βœ¨