Test::OnlySome - Skip individual tests in a *.t file
Easiest: install cpanminus if you don't have it - see https://metacpan.org/pod/App::cpanminus#INSTALLATION. Then run cpanm Test::OnlySome.
cpanminus
cpanm Test::OnlySome
Manually: clone or untar into a working directory. Then, in that directory,
perl Makefile.PL make make test
... and if all the tests pass,
make install
If some of the tests fail, please check the issues and file a new one if no one else has reported the problem yet.
use Test::More; use Test::OnlySome;
You can pick which tests to skip using implicit or explicit configuration. Explicit configuration uses a hashref:
my $opts = { skip => { 2=>true } }; os $opts ok(1, 'This will run'); # Single statement OK os $opts { # Block also OK ok(0, 'This will be skipped'); # Skipped since it's test 2 };
Implicit configuration uses a hashref in the package variable $TEST_ONLYSOME, which Test::OnlySome creates in your package when you use it:
$TEST_ONLYSOME
use
$TEST_ONLYSOME->{skip} = { 2=>true }; os ok(1, 'Test 1'); # This one runs os ok(0, 'Test 2 - should be skipped'); # Skipped since it's test 2
A convenience function to fill in $hashref_options->{skip}.
$hashref_options->{skip}
skip_these $hashref_options, 1, 2; # Skip tests 1 and 2 skip_these 1, 2; # If you are using implicit configuration
Another convenience function: Mark the next test to be skipped. Example:
skip_next; os ok(0, 'This one will be skipped');
The import sub defines the keywords so that they will be exported (!). This is per Keyword::Declare.
import
Keyword os marks a statement that should be excuted only some of the time. Example:
os
os 'main::debug' $hrOpts ok 1,'Something'; # Run "ok 1,'Something'" if hashref $hrOpts indicates. # Save debug information into $main::debug.
Syntax:
os ['debug::variable::name'] $hashref_options <statement | block>
$debug::variable::name will be assigned at compilation time. $hashref_options will be accessed at runtime.
$debug::variable::name
$hashref_options
CAUTION: The given statement or block will be run in its own lexical scope, not in the caller's scope.
Removes the "os" keyword definition.
This routine generates source code that, at runtime, will execute a given only-some test.
Return True if the provided parameter, or $_, is a valid test number.
$_
Returns the appropriate options hashref, and an indication of whether the caller should shift (true for explicit config). Call as _opts($_[0]).
shift
_opts($_[0])
Gets the caller's current $TEST_NUMBER_OS value.
$TEST_NUMBER_OS
Find the caller using a Test::Kit package that uses us, so we can import the keyword the right place.
Print a full stack trace
Exported into the caller's package. A sequential numbering of tests that have been run under "os".
Exported into the caller's package. A hashref of options, of the same format as an explicit-config hashref. Keys are:
n
The number of tests in each "os" call.
skip
A hashref of tests to skip. Test numbers are keys; any truthy value will indicate that the "os" call beginning with that test number should be skipped.
Christopher White, <cxwembedded at gmail.com>
<cxwembedded at gmail.com>
Please report any bugs or feature requests on GitHub, at https://github.com/cxw42/Test-OnlySome/issues.
You can find documentation for this module with the perldoc command.
perldoc Test::OnlySome
You can also look for information at:
The GitHub repository
https://github.com/cxw42/Test-OnlySome
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Test-OnlySome
CPAN Ratings
https://cpanratings.perl.org/d/Test-OnlySome
Search CPAN
https://metacpan.org/release/Test-OnlySome
RT: CPAN's request tracker
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-OnlySome
Version 0.0.5
Copyright 2018 Christopher White.
This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
To install Test::OnlySome, copy and paste the appropriate command in to your terminal.
cpanm
CPAN shell
perl -MCPAN -e shell install Test::OnlySome
For more information on module installation, please visit the detailed CPAN module installation guide.