I am adding a feature to a package that optionally uses DBIish
. I would like to write a few unit tests to ensure that the functionality is working. However, DBIish
should be an optional dependency, meaning you don't need it to install or use the package. How can I skip DBIish
tests if the user does not have DBIish
installed?
Something like:
{
require ::('DBIish');
CATCH {
default {
skip-testing;
}
}
}
... would be ideal, but an optional test flag would also work, but I can't seem to find any documentation on the topic.
If it's about importing a class that should be installed (or not), I always use the following "trick":
my \Foo = try "use Foo; Foo".EVAL;
If it worked, then Foo
will be the class. If it didn't, then Foo
will be Nil
.