NAME Test::Class::Filter::Tags - Selectively run only a subset of Test::Class tests that inclusde/exclude the specified tags. SYNOPSIS # define a test baseclass, to avoid boilerplate package MyTests::Base; # load the filter class. This will both add the filter to Test::Class, as # well as importing the 'Tags' attribute into the current namespace use Test::Class::Filter::Tags # and, of course, inherit from Test::Class; use base qw( MyTests::Base ); 1; package MyTests::Wibble; # using custom baseclass, don't have to worry about importing attribute # class for each test use Base qw( Test::Class ); # can specify both Test and Tags attributes on test methods sub t_foo : Test( 1 ) Tags( quick fast ) { } sub t_bar : Test( 1 ) Tags( loose ) { } sub t_baz : Test( 1 ) Tags( fast ) { } 1; # # in Test::Class driver script, or your Test::Class baseclass # # load the test classes, in whatever manner you normally use use MyTests::Wibble; $ENV{ TEST_TAGS } = 'quick,loose'; Test::Class->runtests; # from the test above, only t_foo and t_bar methods would be run, the # first because it has the 'quick' tag, and the second becuase it has # 'loose' tag. t_baz doesn't have either tag, so it's not run. # Alternatively, can specify TEST_TAGS_SKIP, in a similar fashion, # to *not* run tests with the specified tags DESCRIPTION When used in conjunction with Test::Class tests, that also define Attribute::Method::Tags tags, this class allows filtering of the tests that will be run. If $ENV{ TEST_TAGS } is set, it will be treated as a list of tags, seperated by any combination of whitespace or commas. The tests that will be run will only be the subset of tests that have at least of one these tags specified. Conversely, you may want to run all tests that *don't* have specific tags. This can be done by specifying the tags to exclude in $ENV{ TEST_TAGS_SKIP }. Note that, as per normal Test::Class behaviour, only normal tests will be filtered. Any fixture tests (startup, shutdown, setup and teardown) will still be run, where appropriate, whether they have the given attributes or not. IMPORTS By using this class, you'll get the 'Tags' attribute imported into your namespace. This is required to be able to add Tags attribute to your test methods. METHODS method_has_tag( $class, $method, $tag ) Returns a true value if $tag is defined on $method in $class, or any of $class'es super-classes. This may sound of limited use, but one of the use cases presented to me when developing this module was to have setup fixtures conditionally run if the method that's being tested has a specific tag. TAGS ADDITIVE OVER INHERITANCE When inheriting from test classes, the subclasses will adopt any tags that the superclass methods have, in addition to any that they specify. (ie, tags are addative, when subclass and superclass have the same method with different tags, the tags for the subclass method will be those from both). SEE ALSO Test::Class This class is implemented via the Test::Class filtering mechanism. AUTHOR Mark Morgan BUGS Please send bugs or feature requests through to bugs-Test-Class-Filter-Tags@rt.rt.cpan.org or through web interface . COPYRIGHT AND LICENSE Copyright 2010 Mark Morgan, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.