The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::Skip - Framework to skip tests unless conditions are met

SYNOPSIS

  # load time decision, all the tests in the file will be skipped
  # unless all the conditions are met

  use Test::Skip
        {
        description => 'pre-requisits to test XXX',
         
        # dump all the condition and their state unless all conditions are met 
        verbose => 1,

        unless_has =>
                {
                executables => [ '/usr/bin/rsync', 'git' ],
                modules => ['IPC::Run', ['Data::TreeDumper' => 0.36 ]] ,
                os => [ 'linux', ['Win32' => 'XP']]
                },

        if_has => 
                {
                modules => 
                        {
                        error_text => 'module "Safe" is too old!',
                        modules => ['Safe' => '<2.26'] 
                        },

                user_check =>
                        {
                        'command ps(1) does not supply VSIZE' => \&check_ps_for_VSIZE_field,
                        },
                }

        # use existing modules that implement Skip functionality
        plugins => {executables => 'Test::Skip::UnlessExistsExecutable'},
        } ;

  #---------------------------------------------------
  
  # run time decision
  use Test::Skip qw(:skip_all_test) ;

  # single pre-requisits
  #
  skip_all_tests_unless 'modules' => 'IPC::Run, 'no IPC::Run, needed for test xxx' ;
  skip_all_tests_if 'modules' => ['Safe' => '<2.26'], 'tests need modern versions of Safe'

  # many pre-requisits

  skip_all_tests \%prerequisits, 'text displayed if tests are skipped' ;

  #---------------------------------------------------

  # run time decision, Test::Block style
  use Test::Skip qw(:skip_test) ;  
  
  skip_tests_if 'modules' => ['Safe' => '<2.26'] 
        {
        # many tests using a moder Safe in this block 
        }, 'tests need modern versions of Safe' ;

  my %prerequisits =
        {
        unless_has => { executables => '/usr/bin/rsync', ...},
        if_has => { ... }, 
        } ;

  skip_tests \%prerequisits
        {
        # many tests in this block
        }, 'prerequists missing for test XXX' ;

DESCRIPTION

* This is a placeholder with no implementation yet. Please give feedback on the API *

This module implements a framework that skips tests unless the specified pre-requisits are met.

DOCUMENTATION

SUBROUTINES/METHODS

BUGS AND LIMITATIONS

None so far.

AUTHOR

        Nadim ibn hamouda el Khemir
        CPAN ID: NKH
        mailto: nadim@cpan.org

COPYRIGHT AND LICENSE

Copyright 2010 Nadim Khemir.

This program is free software; you can redistribute it and/or modify it under the terms of either:

  • the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or

  • the Artistic License version 2.0.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Test::Skip

You can also look for information at:

SEE ALSO

Test::Skip::UnlessExistsExecutable, Test::Requires