Test::Some(3)

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

πŸ’– Test::Some β€” test a subset of tests πŸ’–

okay bestie, so Test::Some is a Perl module (it lives in section 3 of the manual, that's the library-functions corner of the man world) and it's about running only some of your tests. yes. selectively. like a queen choosing which of her subjects get an audience. πŸ‘‘


✨ VERSION ✨

this one's version 0.2.1. fresh. current. iconic.


🌸 SYNOPSIS 🌸

use Test::More;

use Test::Some 'foo';

plant tests => 3;

subtest foo => sub { pass };

# will be skipped
subtest bar => sub { fail };

see how foo runs and bar gets left on read? that's the whole point. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically this module lets you run a subset of the subtest tests that are sitting in a test file. not all of them. a curated selection. a vibe check, if you will.

the module declaration takes a whitelist of the subtests you actually wanna run. any subtest that doesn't match any of the whitelist items gets skipped (or potentially bypassed, more on that in a sec).

and here's the slay part: your test files don't even need to be modified, because you can also invoke the module straight from the command-line. like:

$ perl -MTest::Some=foo t/tests.t

no cap. zero edits. just vibes. ✨

if you don't give the module declaration any argument, then the environment variable TEST_SOME gets used as the defaults. so for example, this right here is equivalent to the example above:

$ export TEST_SOME=foo
$ perl -MTest::Some t/tests.t

same energy. different delivery method. 🫢

πŸŽ€ Whitelist items πŸŽ€

'~'

this one tells Test::Some to bypass the non-whitelisted tests instead of skipping them. so like, smaller output, cuter logs, less noise. BUT β€” and this is a big but, listen up β€” the test file would now fail if it has a plan tests = $n> line, because we'll only be reporting on "$n - bypassed" tests. so. just know that. ⚠️

Subtest name

at its most simple, you just pass the names of the subtests you want to run. that's it. that's the whole thing.

# run subtests 'foo' and 'bar'
use Test::Some 'foo', 'bar';

Negation

an item prefixed with a bang (!) is negated.

use Test::Some '!foo';  # run all tests but 'foo'

now lowkey important: a subtest is run if it matches any item in the whitelist. so

use Test::Some '!foo', '!bar';

will run all the tests, because foo is not bar and vice versa. yeah. the negation got negated by the any-match rule. it's giving uno reverse. 😭

Regular expression

a string beginning with a slash (/), or a regular expression object, gets treated as a regex to be compared against the subtest name.

use Test::Some '/foo';  # only tests with 'foo' in their name

# equivalent to
use Test::Some qr/foo/;

Tags

strings prefixed with a colon (:) are considered to be tags.

# run all tests with the 'basic' tag
use Test::Some ':basic';

and you assign tags to a subtest by putting them after the coderef. like so:

subtest foo, sub {
    ...
}, 'tag1', 'tag2';

Test::More's subtest just ignores those trailing arguments, so you can drop them in there without breaking backward compatibility. 🧚 and if you want those tags to be more visible, you can also do:

subtest foo => $_, 'tag1', 'tag2', for sub {
    ...;
};

(that neat trick, incidentally, was pointed out by aristotle. shoutout. πŸŽ€)

Code

you can pass a coderef. it'll get the subtest name and its tags passed in as $_ and %_, respectively.

# run tests with tags 'important' *and* 'auth'
use Test::Some sub {
    $_{important} and $_{auth}
};

a whole custom little filter function. main character energy, honestly. πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€


πŸ’œ AUTHOR πŸ’œ

Yanick Champoux <yanick@cpan.org>


this software is copyright (c) 2015 by Yanick Champoux.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie πŸ’– this was perl v5.42.0, dated 2025-07-25, from the User Contributed Perl Documentation collection. go forth and run only the tests you wanna run. slay. βœ¨πŸ¦‹πŸ’…

πŸ“¦ where this page comes from