Dmitri Tikhonov wrote:
I have a test suite for my distribution (RT-Client-REST) that requires
some modules that the module itself does not require (Test::Exception,
for example).  Since it is not listed as a dependency, some people's
tests fail[1,2].

Question: is it a good idea to put Test::Exception in as a dependency?
My problem with this is that the module itself, once installed, does
not use Test::Exception, so it is not really a dependency.  On the other
hand, I want all tests to run (most of them test exceptions), so I do
not want to 'skip' any tests.

Is it a good idea?  "It depends."

There's an argument to be made for not forcing people to download extra modules. But most of the "build_requires" type approaches don't seem to work well in practice. Module::Install can bundle test dependencies in an inc/ directory, but then you're on the Module::Install treadmill and people are potentially downloading modules multiple times instead of just installing them once.

Personally, I don't really worry too much about including test dependencies as long as the modules are (a) fairly portable and (b) likely to be used by lots of other common modules. I find that preferable to skipping lots of tests or other things. All the dependencies are listed in the META.yml, so if people want to skip my module for having too many dependencies, well, fine.

That said, I will try to minimize test modules a bit if it doesn't sacrifice the ease and convenience of tests. For example, while I wouldn't give up IPC::Run3 for testing scripts, I can (and often do) without Test::Exception.

While the syntax of Test::Exception is nice, I don't find it too terrible to just write:

  eval { lots_of_code() };
  is( $@, '', 'Lives' );

Or:

  eval { code_dies() };
  like( $@, qr/error message/, 'Got an error' );

I originally did this because Test::Exception relies on Sub::Uplevel, which had some problems with other code that uses Sub::Uplevel, but I've taken over and patched Sub::Uplevel, so it should now be fine. So, personally, if you like Test::Exception, I'd go ahead and use it.

Regards,
David Golden

Reply via email to