Test::Cukes(3pm)

๐Ÿ“ฆ
version 0.11 ยท 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

ok so bestie, welcome to Test::Cukes(3pm) โ€” she's a BBD test tool inspired by Cucumber ๐Ÿฅ’โœจ (yes that's "BBD", that's what it says, we don't ask questions, we just vibe).


๐ŸŒธ SYNOPSIS ๐ŸŒธ

Write your test program like this, bestie:

# test.pl
use Test::Cukes;
# use Test::Cukes tests => 3;

feature(<<TEXT);
Feature: writing behavior tests
  In order to make me happy
  As a test maniac
  I want to write behavior tests

  Scenario: Hello World
    Given the test program is running
    When it reaches this step
    Then it should pass
TEXT

Given qr/the (.+) program is (.+)/, sub {
    my ($program_name, $running_or_failing) = @_;
    assert "running program '$program_name'";
};

When qr/it reaches this step/, sub {
    assert "reaches";
};

Then qr/it should pass/, sub {
    assert "passes";
};

runtests;

And when it runs? It looks like this ๐Ÿ‘‡

> perl test.pl
1..3
ok 1 - Given the test program is running
ok 2 - When it reaches this step
ok 3 - Then it should pass

โœจ DESCRIPTION โœจ

Test::Cukes is a testing tool inspired by Cucumber (<http://cukes.info>) ๐Ÿฅ’๐Ÿ’… It lets you write your module test with scenarios. It may be used with Test::More or the other fam of TAP Test::* modules. Internally it uses the Test::Builder::note function to print messages, no cap.

This module implements the Given-When-Then clause only in English hun โ€” that's the whole thing. To use it in your test programs, you feed the feature text into the feature function, define your step handlers, and then run all the tests by calling runtests. Step handlers may live in separate modules, as long as those modules are included before runtests is called, okay? ๐Ÿ‘‘ Each step may use either assert or standard TAP functions such as Test::Simple's ok or Test::More's is to verify the desired result. And if you specify a plan explicitly, be aware: every single step line in your scenario runs an additional test, so it adds to the number of tests you have to indicate. Do the math, bestie ๐Ÿงฎ

If any assertion in the Given block failed, the following When and Then blocks are all skipped. Every last one. Not me getting ghosted by my own test suite ๐Ÿ˜ญ

You don't need to specify the number of tests with plan. Each step block is itself simply one test. If the block died, it's considered failed. Otherwise it's considered as passing. Simple as ๐Ÿ’€

In the call to Test::Cukes::runtests, done_testing will automatically be called for you if you didn't specify a plan. She does it for you, she's generous like that ๐Ÿซถ

Test::Cukes re-exports the assert function from Carp::Assert for you to use in the step block. Freebies โœจ

For more info about how to define feature and scenarios, please read the documents from <http://cukes.info>. Go read, bestie, iykyk ๐Ÿ“–


๐Ÿ’œ AUTHOR ๐Ÿ’œ

Kang-min Liu <gugod@gugod.org> โ€” the icon, the moment, the main character ๐Ÿ‘‘

๐ŸŒˆ CONTRIBUTORS ๐ŸŒˆ

Tatsuhiko Miyagawa, Tristan Pratt โ€” squad goals, fr fr ๐Ÿซถ


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹


๐ŸŽ€ LICENSE ๐ŸŽ€

This is free software, licensed under:

The MIT (X11) License

slay, it's free, go wild ๐Ÿ’…


โญ DISCLAIMER OF WARRANTY โญ

ok so this part is legally screaming at you in all caps, but it's important so we're keeping the energy ๐Ÿšจ

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

bestie that's the whole legal speech, no skipping, no summarizing, we respect the lawyers ๐Ÿซก

and that's the page, babe ๐Ÿ’– this manual came to you courtesy of perl v5.36.0, dated 2022-10-16 โ€” shoutout to Test::Cukes(3pm), she ate and left no crumbs ๐Ÿ‘‘โœจ bye bestie, go write some scenarios ๐Ÿฅ’๐ŸŒˆ

๐Ÿ“ฆ where this page comes from