Test::...:Simple(3pm)

πŸ“¦
version 1.06 Β· 2 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸŽ€ NAME πŸŽ€

Test::XML::Simple β€” easy testing for XML πŸ’– no cap, that's literally it.

This is the manual page for Test::XML::Simple(3pm), part of the User Contributed Perl Documentation (the ✨ user-contributed ✨ corner of the Perl docs, iykyk).


πŸ¦‹ SYNOPSIS πŸ¦‹

okay bestie, here's the whole vibe in one block:

  use Test::XML::Simple tests => 8;

  # pass string with XML as argument
  xml_valid $xml, "Is valid XML";
  xml_node $xml, "/xpath/expression", "specified xpath node is present";
  xml_is, $xml, '/xpath/expr', "expected value", "specified text present";
  xml_like, $xml, '/xpath/expr', qr/expected/, "regex text present";
  xml_is_deeply, $xml, '/xpath/expr', $xml2, "structure and contents match";

  # XML::LibXML::Document can be passed as argument too
  #  that allow you to test a big documents with several tests
  my $xml_doc = XML::LibXML->createDocument( '1.0' );
  xml_valid $xml_doc, 'Is valid XML';
  xml_node $xml_doc, '/xpath/expression', 'specified xpath node is present';
  xml_like, $xml_doc, '/xpath/expression', qr/expected result/, 'regex present';

  # Not yet implemented:
  # xml_like_deeply would be nice too...

not the # Not yet implemented: comment at the end πŸ’€ she's honest, we love that for her.


🌸 DESCRIPTION 🌸

Test::XML::Simple is a very basic class for testing XML. It uses the XPath syntax to locate nodes within the XML, which is giving main character energy honestly. You can also check all or part of the structure vs. an XML fragment. ✨

And here's the little detail that makes life so much easier: all routines accept as their first argument either a string with XML or an XML::LibXML::Document object. 🫢


πŸ’… TEST ROUTINES πŸ’…

one bullet-free list, one icon per routine, let's gooo:

🧚 xml_valid $xml, 'test description'

Pass an XML file or fragment to this test; it succeeds if the XML (fragment) is valid. βœ…

🌈 xml_node $xml, $xpath, 'test description'

Checks the supplied XML to see if the node described by the supplied XPath expression is present. Test fails if it is not present. πŸ”

πŸ’– xml_is_long $xml, $xpath, $value, 'test description'

Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::More's is function to do the comparison.

πŸŽ€ xml_is $xml, $xpath, $value, 'test description'

Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::LongString's is_string function to do the test.

πŸ¦‹ xml_like_long $xml, $xpath, $regex, 'test description'

Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::More's like function to do the comparison.

yes bestie, "the the" is in the original. I'm not touching it. it's iconic. πŸ’€

⭐ xml_like $xml, $xpath, $regex, 'test description'

Find the XML corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::LongString's like_string function to do the test.

πŸ‘‘ xml_is_deeply_long $xml, $xpath, $xml2, 'test description'

Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied. Succeeds if they match in structure and content. Uses Test::More's is function to do the comparison.

🌸 xml_is_deeply $xml, $xpath, $xml2, 'test description'

Find the piece of XML corresponding to the XPath expression, and compare its structure and contents to the second XML (fragment) supplied. Succeeds if they match in structure and content. Uses Test::LongString's is_string function to do the test.


✨ AUTHOR ✨

Joe McMahon, <mcmahon@cpan.org> πŸ‘‘


πŸ’œ LICENSE πŸ’œ

Copyright (c) 2005-2013 by Yahoo! and Joe McMahon

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available. 🫢


πŸ”₯ SEE ALSO πŸ”₯

  • XML::LibXML
  • Test::More
  • Test::Builder

go read those too bestie, they're the supporting cast 🎬


and that's the whole page, fr fr πŸ’– this was perl v5.40.0, dated 2024-11-17, and the manpage itself is Test::...:Simple(3pm) β€” slay, bye bestie! πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from