On 31/12/06, Paul LeoNerd Evans <[EMAIL PROTECTED]> wrote:
I recently stumbled upon Test::Exception, and wondered if it might make
my test scripts any better.. So far I'm struggling to see any benefit,
for quite a lot of cost.

Without using this module, my tests look like:

    eval { code() };
    ok( $@, 'An exception is raised' );

(and possibly either of)
    like( $@, qr/some string match/, 'Exception type' );
(or)
    ok( [EMAIL PROTECTED]>isa( "Thing" ), 'Exception type' );
(to check the type)

Whereas, if I want to use the module, I have to first note that it isn't
standard install, so I should start the test with something like:

    eval { require Test::Exception; import Test::Exception; };
    my $can_test_exception = $@ ? 0 : 1;

Then each test that might use it should be:

    SKIP: {
        skip "No Test::Exception", 1 unless $can_test_exception;

        dies_ok( sub { code() },
                 'An exception is raised' );
    }

So, a lot more code, to achieve the same end result... Plus, I'm now in
the situation where if Test::Exception isn't installed, the test won't
be run at all.

I think the code about should die comlaining about dies_ok() is
unknown. So you need to do even more.

Have I missed something here? Does Test::Exception provide me with some
greater functionallity I haven't yet observed? Or should I just not
bother using it?

Don't you get the same problem with any non-standard test module?

If you alread yhave some CPAN dependencies then adding another for
testing is perfecctly reasonable. It would be nice if the various CPAN
tools could understand the difference between a runtime dependecy and
a test-time one though,

F

Reply via email to