Debian Codegraph @

README

raw
1 NAME
2 Test::XML::Simple - easy testing for XML
3
4 SYNOPSIS
5 use Test::XML::Simple tests => 8;
6
7 # pass string with XML as argument
8 xml_valid $xml, "Is valid XML";
9 xml_node $xml, "/xpath/expression", "specified xpath node is present";
10 xml_is, $xml, '/xpath/expr', "expected value", "specified text present";
11 xml_like, $xml, '/xpath/expr', qr/expected/, "regex text present";
12 xml_is_deeply, $xml, '/xpath/expr', $xml2, "structure and contents match";
13
14 # XML::LibXML::Document can be passed as argument too
15 # that allow you to test a big documents with several tests
16 my $xml_doc = XML::LibXML->createDocument( '1.0' );
17 xml_valid $xml_doc, 'Is valid XML';
18 xml_node $xml_doc, '/xpath/expression', 'specified xpath node is present';
19 xml_like, $xml_doc, '/xpath/expression', qr/expected result/, 'regex present';
20
21 # Not yet implemented:
22 # xml_like_deeply would be nice too...
23
24 DESCRIPTION
25 "Test::XML::Simple" is a very basic class for testing XML. It uses the
26 XPath syntax to locate nodes within the XML. You can also check all or
27 part of the structure vs. an XML fragment. All routines accept as first
28 argument string with XML or XML::LibXML::Document object.
29
30 TEST ROUTINES
31 xml_valid $xml, 'test description'
32 Pass an XML file or fragment to this test; it succeeds if the XML
33 (fragment) is valid.
34
35 xml_node $xml, $xpath, 'test description'
36 Checks the supplied XML to see if the node described by the supplied
37 XPath expression is present. Test fails if it is not present.
38
39 xml_is_long $xml, $xpath, $value, 'test description'
40 Finds the node corresponding to the supplied XPath expression and
41 compares it to the supplied value. Succeeds if the two values match.
42 Uses Test::More's "is" function to do the comparison.
43
44 xml_is $xml, $xpath, $value, 'test description'
45 Finds the node corresponding to the supplied XPath expression and
46 compares it to the supplied value. Succeeds if the two values match.
47 Uses Test::LongString's "is_string" function to do the test.
48
49 xml_like_long $xml, $xpath, $regex, 'test description'
50 Find the XML corresponding to the the XPath expression and check it
51 against the supplied regular expression. Succeeds if they match. Uses
52 Test::More's "like" function to do the comparison.
53
54 xml_like $xml, $xpath, $regex, 'test description'
55 Find the XML corresponding to the the XPath expression and check it
56 against the supplied regular expression. Succeeds if they match. Uses
57 Test::LongString's "like_string" function to do the test.
58
59 xml_is_deeply_long $xml, $xpath, $xml2, 'test description'
60 Find the piece of XML corresponding to the XPath expression, and compare
61 its structure and contents to the second XML (fragment) supplied.
62 Succeeds if they match in structure and content. Uses Test::More's "is"
63 function to do the comparison.
64
65 xml_is_deeply $xml, $xpath, $xml2, 'test description'
66 Find the piece of XML corresponding to the XPath expression, and compare
67 its structure and contents to the second XML (fragment) supplied.
68 Succeeds if they match in structure and content. Uses Test::LongString's
69 "is_string" function to do the test.
70
71 AUTHOR
72 Joe McMahon, <[email protected]>
73
74 LICENSE
75 Copyright (c) 2005-2013 by Yahoo! and Joe McMahon
76
77 This library is free software; you can redistribute it and/or modify it
78 under the same terms as Perl itself, either Perl version 5.6.1 or, at
79 your option, any later version of Perl 5 you may have available.
80
81 SEE ALSO
82 XML::LibXML, Test::More, Test::Builder.
83