Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/corion/test-html-content
Perl extension for testing HTML output
https://github.com/corion/test-html-content
Last synced: 7 days ago
JSON representation
Perl extension for testing HTML output
- Host: GitHub
- URL: https://github.com/corion/test-html-content
- Owner: Corion
- Created: 2023-01-20T10:31:33.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-07-23T07:48:40.000Z (over 1 year ago)
- Last Synced: 2024-10-11T21:18:13.730Z (about 1 month ago)
- Language: Perl
- Size: 89.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
Test::HTML::Content - Perl extension for testing HTML output
DESCRIPTION
This is a module to test the HTML output of your programs in simple
test scripts. It can test a scalar (presumably containing HTML) for
the presence (or absence, or a specific number) of tags having (or
lacking) specific attributes. Unspecified attributes are ignored,
and the attribute values can be specified as either scalars (meaning
a match succeeds if the strings are identical) or regular expressions
(meaning that a match succeeds if the actual attribute value is matched
by the given RE) or undef (meaning that the attribute must not
be present).If you want to specify or test the deeper structure
of the HTML (for example, META tags within the BODY) or the (textual)
content of tags, you will have to resort to C,C
and C, which take an XPath expression. If you find yourself crafting
very complex XPath expression to verify the structure of your output, it is
time to rethink your testing process and maybe use a template based solution
or simply compare against prefabricated files as a whole.The used HTML parser is HTML::TokeParser, the used XPath module
is XML::XPath or XML::LibXML. XML::XPath needs valid xHTML, XML::LibXML
will try its best to force your code into xHTML, but it is best to
supply valid xHTML (snippets) to the test functions.If no XPath parsers/interpreters are available, the tests will automatically
skip, so your users won't need to install XML::XPath or XML::LibXML. The module
then falls back onto a crude implementation of the core functions for tags,
links, comments and text, and the diagnostic output of the tests varies a bit.The test functionality is derived from L, and the export
behaviour is the same. When you use Test::HTML::Content, a set of
HTML testing functions is exported into the namespace of the caller.INSTALLATION
This is a Perl module distribution. It should be installed with whichever
tool you use to manage your installation of Perl, e.g. any ofcpanm .
cpan .
cpanp -i .Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
Should you wish to install this module manually, the procedure isperl Makefile.PL
make
make test
make installSEE ALSO
perl(1), L,L,L.
AUTHOR
Max Maischein [email protected]
LICENSE
This code may be distributed under the same terms as Perl itself.