NAME

MOBY::Client::MobyUnitTest - Create Unit Tests and test your service


SYNOPSIS

        use MOBY::Client::MobyUnitTest;
        my $x = MOBY::Client::MobyUnitTest->new;
        # set expected output
        $x->expected_output($control_xml);
        # test expected output with XML output
        my $success = $x->test_output_xml($test_file);
        print "XML matches!\n" if $success;
        # set xpath statement
        $x->xpath($some_xpath);
        # test xpath statement
        $success = $x->test_xpath($test_xml);
        print "xpath success!\n" if $success;
        # set regex statement
        $x->regex($some_regex);
        # test regex statement
        $success = $x->test_regex($test_xml); 
        print "regex success!\n" if $success;
        # get XML differences if any
        my $differences = $x->get_xml_differences($test_xml);


DESCRIPTION

This module is used for providing unit test case information for any particular service, as well as actually performing the tests on the service.


AUTHORS

 Edward Kawas (edward.kawas [at] gmail [dot] com)


SUBROUTINES

new

constructs a new MobyUnitTest reference. parameters (all optional) include:

example_input - example input to pass to our service when testing it
expected_output - service output xml that is expected given the example input
regex - the regular expression to match against
xpath - the xpath statement to match against

example_input

getter/setter - use to get/set the example input for the service that we are testing.

expected_output

getter/setter - use to get/set the expected output for the service that we are testing given example_input.

regex

getter/setter - use to get/set the regular expression that will be applied agaisnt the actual output for the service that we are testing.

xpath

getter/setter - use to get/set the xpath expression that will be applied against the actual output for the service that we are testing.

test_output_xml

subroutine that determines whether or not the passed in output XML is semantically similar to expected_output.

parameters - a scalar string of XML (or a file location) to test expected_output against.

a true value is returned if both XML docs are semantically similar, otherwise undef is returned.

test_regex

subroutine that applies regex to the passed in output XML.

parameters - a scalar string of XML to test against.

a true value is returned if the regular expression matches, otherwise undef is returned.

test_xpath

subroutine that applies xpath to the passed in output XML.

parameters - a scalar string of XML (or a file location) to test against.

a true value is returned if the xpath statement matches 1 or more nodes in the XML, otherwise undef is returned.

get_xml_differences

subroutine that retrieves any differences found when comparing expected_output XML and the XML passed in to this sub.

parameters - a scalar string of XML to test expected_output against.

an array ref of strings representing the differences found between xml docs is returned.