Test::If(3pm)

Test::If3pm

Test only if ...

Usage

Generic usage

    use Test::More;
    use Test::If 'Test::Something', [ tests => N ];
    
    # Is equal to
    
    use Test::More;
    eval q{ use Test::Something; 1 } or plan skip_all => 'Module Test::Something required for this test';
    plan tests => N;
    
    use Test::More;
    use Test::If sub { $ENV{TEST_AUTHOR} }, [ tests => N ];
    
    # Is equal to
    
    use Test::More;
    $ENV{TEST_AUTHOR} or plan skip_all => "Test condition not met";
    plan tests => N;

You can also combine options and it is allowed to omit plan options, if it is run by loaded module or you want to load it manually

For example common "pod-coverage.t":

    use Test::More;
    use Test::If
        sub { $ENV{TEST_AUTHOR} },  # Checked first $ENV{TEST_AUTHOR}, otherwise skip
        'Test::Pod::Coverage 1.08', # Use Test::Pod::Coverage of at least version 1.08
        'Pod::Coverage 0.18',       # And want Pod::Coverage at least of version 0.18
    ;
    
    all_pod_coverage_ok();

If some of conditions will not be met, test will be skipped.

Version

Version 0.01

Releases

5 releases since Debian 9 (Stretch); the text changed 2 times.

  1. 9–10
  2. 11
  3. 12–13

Author

Mons Anderson, "<mons at cpan.org>"

From libtest-if-perl 0.01-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.