TAP::Parser::Result::Test(3p) Perl Programmers Reference Guide #
TAP::Parser::Result::Test(3p) Perl Programmers Reference Guide
NNAAMMEE #
TAP::Parser::Result::Test - Test result token.
VVEERRSSIIOONN #
Version 3.44
DDEESSCCRRIIPPTTIIOONN #
This is a subclass of TAP::Parser::Result. A token of this class will be
returned if a test line is encountered.
1..1
ok 1 - woo hooo!
OOVVEERRRRIIDDDDEENN MMEETTHHOODDSS #
This class is the workhorse of the TAP::Parser system. Most TAP lines
will be test lines and if "$result->is_test", then you have a bunch of
methods at your disposal.
IInnssttaannccee MMeetthhooddss _"_o_k_"
my $ok = $result->ok;
Returns the literal text of the "ok" or "not ok" status.
_"_n_u_m_b_e_r_"
my $test_number = $result->number;
Returns the number of the test, even if the original TAP output did not
supply that number.
_"_d_e_s_c_r_i_p_t_i_o_n_"
my $description = $result->description;
Returns the description of the test, if any. This is the portion after
the test number but before the directive.
_"_d_i_r_e_c_t_i_v_e_"
my $directive = $result->directive;
Returns either "TODO" or "SKIP" if either directive was present for a
test line.
_"_e_x_p_l_a_n_a_t_i_o_n_"
my $explanation = $result->explanation;
If a test had either a "TODO" or "SKIP" directive, this method will
return the accompanying explanation, if present.
not ok 17 - 'Pigs can fly' # TODO not enough acid
For the above line, the explanation is _n_o_t _e_n_o_u_g_h _a_c_i_d.
_"_i_s___o_k_"
if ( $result->is_ok ) { ... }
Returns a boolean value indicating whether or not the test passed.
Remember that for TODO tests, the test always passes.
If the test is unplanned, this method will always return false. See
"is_unplanned".
_"_i_s___a_c_t_u_a_l___o_k_"
if ( $result->is_actual_ok ) { ... }
Returns a boolean value indicating whether or not the test passed,
regardless of its TODO status.
_"_a_c_t_u_a_l___p_a_s_s_e_d_"
Deprecated. Please use "is_actual_ok" instead.
_"_t_o_d_o___p_a_s_s_e_d_"
if ( $test->todo_passed ) {
# test unexpectedly succeeded
}
If this is a TODO test and an 'ok' line, this method returns true.
Otherwise, it will always return false (regardless of passing status on
non-todo tests).
This is used to track which tests unexpectedly succeeded.
_"_t_o_d_o___f_a_i_l_e_d_"
# deprecated in favor of 'todo_passed'. This method was horribly misnamed.
This was a badly misnamed method. It indicates which TODO tests
unexpectedly succeeded. Will now issue a warning and call "todo_passed".
_"_h_a_s___s_k_i_p_"
if ( $result->has_skip ) { ... }
Returns a boolean value indicating whether or not this test has a SKIP
directive.
_"_h_a_s___t_o_d_o_"
if ( $result->has_todo ) { ... }
Returns a boolean value indicating whether or not this test has a TODO
directive.
_"_a_s___s_t_r_i_n_g_"
print $result->as_string;
This method prints the test as a string. It will probably be similar,
but not necessarily identical, to the original test line. Directives are
capitalized, some whitespace may be trimmed and a test number will be
added if it was not present in the original line. If you need the
original text of the test line, use the "raw" method.
_"_i_s___u_n_p_l_a_n_n_e_d_"
if ( $test->is_unplanned ) { ... }
$test->is_unplanned(1);
If a test number is greater than the number of planned tests, this method
will return true. Unplanned tests will _a_l_w_a_y_s return false for "is_ok",
regardless of whether or not the test "has_todo".
Note that if tests have a trailing plan, it is not possible to set this
property for unplanned tests as we do not know it's unplanned until the
plan is reached:
print <<'END';
ok 1
ok 2
1..1
END #
perl v5.36.3 2023-02-15 TAP::Parser::Result::Test(3p)