The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Able::Role::Meta::Class - Main metarole

DESCRIPTION

This metarole gets applied to the Moose::Meta::Class metaclass objects for all Test::Able objects. This metarole also pulls in Test::Able::Planner.

ATTRIBUTES

method_types

The names of the different types of test-related methods. The default set is startup, setup, test, teardown, and shutdown.

*_methods

The test-related method lists. There will be one for each method type. The default set will be:

startup_methods setup_methods test_methods teardown_methods shutdown_methods

These lists are what forms the basis of the test execution plan.

The lists themselves will be coerced into Test::Able::Method::Array objects just for the convenience of overloading for hash access. The elements of the lists will be Test::Able::Role::Meta::Method-based method metaclass objects.

test_objects

The list of Test::Able::Object-based objects that the test runner object will iterate through to make up the test run.

current_test_object

The test object that is currently being executed (or introspected).

current_test_method

The method metaclass object of the associated test method. This is only useful from within a setup or teardown method. Its also available in the test method itself but current_method() would be exactly the same in a test method and its shorter to type.

current_method

The method metaclass object of the currently executing test-related method.

test_runner_object

The test object that will be running the show. It may itself be in the test_objects list. The run_tests() method sets this value to its invocant.

dry_run

Setting this true will cause all test-related method execution to be skipped. This means things like method exception handling, method plan handling, and Test::Builder integration will also not happen. One use of this could be to print out the execution plan. The default is 0.

on_method_plan_fail

Determines what is done, if anything, when the observed method plan doesn't match the expected method plan after the test-related method runs. If this attribute is not set then nothing special is done. Setting this to log or die will cause the failure to be logged via log() or just died upon. The default is log.

on_method_exception

Determines what is done, if anything, when an exception is thrown within a test-related method.

If this attribute isn't set then the exception is simply rethrown. This is the default.

If its set to "continue" then the exception will be silently ignored.

And if set to "continue_at_level" the exception will also be silently ignored and the test runner will skip over lower levels, if there are any, of the test execution plan. The levels are defined as follows. The startup and shutdown methods are at the first level. The setup and teardown methods are the second level. And test methods are the third and last level. Or in visual form:

 startup
     setup
         test
     teardown
 shutdown

In addition, when this attribute is set to continue or continue_at_level the exceptions will be recorded in the method_exceptions attribute of the currently executing test object.

There is only one way to cause a fatal exception when this attribute is set to continue or continue_at_level. And that is to throw a Test::Able::FatalException exception.

method_exceptions

List of exceptions that have occurred while inside a test-related method in this test object. Each element of the list is a hashref that looks like this:

 {
     method    => $self->current_method,
     exception => $exception,
 }

METHODS

run_tests

The main test runner method. Iterates over test_objects list calling run_methods() to run through the test execution plan.

Manages test_runner_object, current_test_object, runner_plan, and last_runner_plan along the way.

run_methods

Executes a test-related method list as part of the test execution plan. Takes one argument and that's the name of the test-related method type. Also, for each test method, it calls run_methods() for the setup and teardown method lists.

build_methods

Builds a test-related method list from the method metaclass objects associated with this metaclass object. The method list is sorted alphabetically by method name. Takes one argument and that's the name of the test-related method type.

build_all_methods

Convenience method to call build_methods() for all method types.

clear_all_methods

Convenience method to clear all the test-related method lists out.

log

All logging goes through this method. It sends its args along to Test::Builder::diag. And only if $ENV{TEST_VERBOSE} is set.

clear_plan

Special purpose plan clearer that dumps the test object's plan and the test runner's plan in one shot.

AUTHOR

Justin DeVuyst, justin@devuyst.com

COPYRIGHT AND LICENSE

Copyright 2009 by Justin DeVuyst.

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