Hello dear esteemed monks,
More than once I felt an urge to put a piece of a unit test script into production code to see what's actually happening there.
Now there is excellent Test::More that provides a very terse, recognizable, and convenient language to build unit test. Unfortunately, it is not quite useful for production code. There are also multiple runtime assertion solutions, but they mostly focus on optimizing themselves out.
My new module Assert::Refute is here to try and bridge the gap. The usage is as follows:
use My::Module; use Assert::Refute qw(:all), {on_fail => 'carp'}; use Assert::Refute::T::Numeric; my $foo = My::Module->bloated_untestable_method; refute_these { like $foo->{bar}, qr/f?o?r?m?a?t/; can_ok $foo->{baz}, qw(do_this do_that frobnicate); is_between $foo->{price}, 10, 1000, "Price is reasonable"; };
And this can be copied-and-pasted verbatim into a unit testing script. So why bother with runtime assertions? Possible reasons include:
Main features include:
This project continues some of my previous posts. Despite humble 0.07 version and documentation mentioning it's alpha, I think it is ready to be shown to the public now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Now released: Assert::Refute - A unified testing and assertion tool
by stevieb (Canon) on Jan 02, 2018 at 22:42 UTC | |
by Dallaylaen (Chaplain) on Jan 04, 2018 at 12:20 UTC | |
by Dallaylaen (Chaplain) on Jan 07, 2018 at 12:52 UTC | |
by Dallaylaen (Chaplain) on Jan 05, 2018 at 12:06 UTC |