Actions Status MetaCPAN Release

NAME

Test2::Plugin::SubtestFilter - Filter subtests by name

SYNOPSIS

# t/test.t
use Test2::V0;
use Test2::Plugin::SubtestFilter;

subtest 'foo' => sub {
    ok 1;
    subtest 'bar' => sub { ok 1 };
};

subtest 'baz' => sub {
    ok 1;
};

done_testing;

Then run with filtering:

# Run only 'foo' subtest and all its children
$ SUBTEST_FILTER=foo prove -lv t/test.t

# Run nested 'bar' subtest (and its parent 'foo')
$ SUBTEST_FILTER=bar prove -lv t/test.t

# Use regex patterns
$ SUBTEST_FILTER='ba' prove -lv t/test.t  # Matches 'bar' and 'baz'

# Run all tests (no filtering)
$ prove -lv t/test.t

DESCRIPTION

Test2::Plugin::SubtestFilter is a Test2 plugin that allows you to selectively run specific subtests based on environment variables. This is useful when you want to run only a subset of your tests during development or debugging.

FILTERING BEHAVIOR

The plugin matches subtest names using partial matching (substring or regex pattern). For nested subtests, the full name is constructed by joining parent and child names with spaces.

How Matching Works

METHODS

apply_plugin

Test2::Plugin::SubtestFilter->apply_plugin($target_package, $target_file);

Applies the subtest filtering functionality to the specified package. Normally called automatically via import(). For advanced users only.

ENVIRONMENT VARIABLES

CAVEATS

SEE ALSO

LICENSE

Copyright (C) kobaken.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

kobaken kentafly88@gmail.com