Test::...p::Obj(3pm)

πŸ“¦
version 0.0306 Β· 2 versions
, in fedora 43

πŸ’– Test::...p::Obj(3pm) β€” the group chat edition πŸ’–

okay so bestie, you're looking at Test::...p::Obj(3pm), straight outta the User Contributed Perl Documentation collection. (yes the name is literally truncated with dots in the middle, that's not me being lazy, that's just how it's filed, iykyk ✨) it's a whole module, and no cap, it's a certified banger for debugging your tests.


🌸 NAME 🌸

Test::Run::Trap::Obj β€” it's a wrapper around Test::Trap for trapping errors. that's it, that's the whole vibe. lowkey iconic πŸŽ€


✨ SYNOPSIS ✨

here's how you actually use it, copy-paste friendly:

    my $got = Test::Run::Trap::Obj->trap_run({
        args => [test_files => ["t/sample-tests/simple"]]
    });

    $got->field_like("stdout", qr/All tests successful/,
        "Everything is OK."
    );

like. look at that. you trap the run, you get $got, you check the fields. slay πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so this class is a wrapper around Test::Trap. the whole point β€” the entire reason she exists β€” is that when an assertion fails, the diagnostics print out all the relevant and trapped fields for easy debugging. no more sitting there like 🧍 wondering what actually went wrong. she tells you. main character energy fr fr.


πŸ‘‘ METHODS πŸ‘‘

one bullet per method, because we are thorough and we are cute:

  • $trapper->diag_all() β€” calls Test::More's diag() with all the trapped fields, like stdout, stderr, etc. basically a full dump of everything she caught. ✨
  • $trapper->field_like($what, $regex, $message) β€” a wrapper for Test::More's like(), except it also emits more diagnostics on failure. so when it goes wrong, you get the tea. πŸ“
  • $trapper->field_unlike($what, $regex, $msg) β€” a wrapper for unlike(). same energy, opposite direction. πŸ’œ
  • $trapper->field_is($what, $expected, $msg) β€” a wrapper for is(). classic. reliable. we love her. πŸŽ€
  • $trapper->field_is_deeply($what, $expected, $msg) β€” a wrapper for is_deeply(). for when your data structures are deep and you need someone to actually compare them properly. 🧚
  • my $got = Test::Run::Trap::Obj->trap_run({class => $class, args => \@args, run_func => $func}) β€” runs "$class-"$func()> with the arguments @args placed into a hash-ref, traps the results, and returns a results object. the whole trap-and-report pipeline in one call, periodt. πŸ”₯

🌈 AUTHOR 🌈

Shlomi Fish, <http://www.shlomifish.org/>. king behaviour. πŸ‘‘


πŸ’€ LICENSE πŸ’€

This file is licensed under the MIT X11 License:

http://www.opensource.org/licenses/mit-license.php

(go read it, it's short, it's giving "do whatever just keep the notice") πŸ’–


🫢 SEE ALSO 🫢

  • Test::Trap
  • Test::More

go read those too, they're the co-stars of this whole situation. πŸ¦‹


and that's the page!! perl v5.42.0, dated 2025-07-25, and yes the page is filed under Test::...p::Obj(3pm) β€” thanks for coming to my ted talk, mwah πŸ’…βœ¨

πŸ“¦ where this page comes from