NAME
XML::Compile::Tester - support XML::Compile related regression testing
INHERITANCE
XML::Compile::Tester
is a Exporter
SYNOPSIS
use XML::Compile::Tester;
set_compile_defaults validation => 0;
my $reader = create_reader $schema, "my reader", $type;
my $writer = create_writer $schema, "my writer", $type;
my $error = reader_error $schema, $type, $xml;
my $output = $templ_xml $schema, $type, @options;
my $output = $templ_perl $schema, $type, @options;
DESCRIPTION
The XML::Compile module suite has extensive regression testing. Probably, you want to do regression testing as well. This module provide functions which simplify writing tests for XML::Compile related distributions.
FUNCTIONS
compare_xml(XML, EXPECTED, [COMMENT])
Compare the XML (either a string or a XML::LibXML::Element) with the EXPECTED string. Both sources are stripped from layout before comparing.
In a future release, this algorithm will get improved to compare the parsed XML node trees, not the strings.
create_reader(SCHEMA, COMMENT, TYPE, OPTIONS)
Create a reader for TYPE. One test is created, reporting success or failure of the creation.
Of course, XML::Compile::Schema subroutine compile is being called, with some options. By default, check_values
is true, and include_namespaces
is false. These values can be overruled using set_compile_defaults(), and with the OPTIONS parameter list.
example:
my $type = pack_type 'type-namespace', 'type-localname';
my $reader = create_reader $schema, 'my test', $type, check_occurs => 0;
create_writer(SCHEMA, COMMENT, TYPE, OPTIONS)
Create a writer for TYPE. One test (in the Test::More sense) is created, reporting success or failure of the creation.
Of course, XML::Compile::Schema subroutine compile is being called, with some options. By default, check_values
and use_default_prefix
are true, and include_namespaces
is false. These values can be overruled using set_compile_defaults(), and with the OPTIONS parameter list.
example:
my $type = pack_type 'type-namespace', 'type-localname';
my $writer = create_writer $schema, 'my test', $type;
reader_error(SCHEMA, TYPE, XML)
Parsing the XML to interpret the TYPE should return an error. The error text is returned.
set_compile_defaults(OPTIONS)
Each call to create a reader or writer (also indirectly) with XML::Compile::Schema subroutine compile will get these OPTIONS passed, on top (and overruling) the usual settings.
example:
set_compile_defaults include_namespaces => 1, validate => 0;
set_default_namespace(TESTNS)
Defined which namespace to use when a relative (only localName) type is provided. By default, this is undef
(an error when used)
templ_perl(SCHEMA, TYPE, OPTIONS)
Create an example template for TYPE, as Perl data structure (like Data::Dumper) The OPTIONS are passed to XML::Compile::Schema subroutine template.
templ_xml(SCHEMA, TYPE, OPTIONS)
Create an example template for TYPE, as XML message. The OPTIONS are passed to XML::Compile::Schema subroutine template.
writer_error(SCHEMA, TYPE, DATA)
Translating the Perl DATA into the XML type should return a validation error, which is returned.
writer_test(WRITER, DATA, [DOC])
Run the test with a compiled WRITER, which was created with create_writer(). When no DOC (XML::LibXML::Document object) was specified, then one will be created for you.
SEE ALSO
This module is part of XML-Compile-Tester distribution version 0.01, built on April 21, 2008. Website: http://perl.overmeer.net/xml-compile/ All modules in this suite: "XML::Compile", "XML::Compile::SOAP", "XML::Compile::SOAP::Daemon", "XML::Compile::Tester", "XML::Compile::Dumper".
Please post questions or ideas to http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile|the mailinglist For life contact with other developers, visit the #xml-compile channal on IRC.
LICENSE
Copyrights 2008 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html