HTTP::WebTest::TestResult - Test results class


HTTP-WebTest documentation Contained in the HTTP-WebTest distribution.

Index


Code Index:

NAME

Top

HTTP::WebTest::TestResult - Test results class

SYNOPSIS

Top

    use HTTP::WebTest::TestResult;

    my $result = HTTP::WebTest::TestResult;

    my $bool = $result->ok;
    $result->ok($bool);
    my $comment = $result->comment;
    $result->comment($comment);

    if($result) { ... }

DESCRIPTION

Top

Objects of this class represent test results. Test results are basicly ok/not ok and some attached commentary.

This class overloads bool operation so it can be directly used in statements that require boolean values.

    if($result) { ... }

is equivalent to

    if($result->ok) { ... }

CLASS METHODS

Top

new ()

Constructor

Returns

A new HTTP::WebTest::TestResult object.

ok ($optional_ok)

If $optional_ok is passed, Defines whether or not test is successful.

Returns

True if test is successful. False otherwise.

comment ($optional_comment)

If $optional_comment is passed, sets test result comment.

Returns

A test result comment.

COPYRIGHT

Top

SEE ALSO

Top

HTTP::WebTest

HTTP::WebTest::API (HTTP::WebTest::API)

HTTP::WebTest::Test


HTTP-WebTest documentation Contained in the HTTP-WebTest distribution.
# $Id: TestResult.pm,v 1.5 2003/03/02 11:52:10 m_ilya Exp $

package HTTP::WebTest::TestResult;

use strict;

use HTTP::WebTest::Utils qw(make_access_method);

use overload bool => \&_bool;

sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;

    my $self = bless {}, $class;

    return $self;
}

*ok = make_access_method('OK');

*comment = make_access_method('COMMENT');

# this method is used to overload 'bool' operation.  'ok' can't be used
# directly because method which is overloads operation is called with
# some additional arguments which doesn't play nice with accessor
# method like 'ok'
sub _bool { shift->ok }

1;