Testing XML
Testing XML
Benefits of Test Driven Development are Well Known
More and More Applications Are Generating XML
XML is not Just a Text File
Different ways of representing the same syntax
Content can change but still be OK
Key Question
An XML document
An Alternate Representation of the Same document
A Representation of the Same Information in a Different Document
The XML Infoset
Element Information Items
The InfoSet Omits:
Infoset significant details that sometimes should ignored anyway
Direct Testing with DOM
DOM Example
Canonical XML
A Canonicalized Document
JUnit Canonicalization (using XOM)
Document Subset Canonicalization
JUnit Document Subset Canonicalization (using XOM 1.1)
Exclusive XML Canonicalization
JUnit Exclusive Document Subset Canonicalization
Canonicalization tools and libraries
Validity
DTDs
Validating via JUnit
Changing the DTD
Mock DOCTYPE
W3C Schemas
JUnit test for W3C Schemas
RELAX NG schema
JUnit test for RELAX NG Schemas
XPath
Some XPath Tests for the plist
XPath in a JUnit test
Writing as XSLT
Combining XPath with Java
XPath+Java Test
Schematron
Schematron Syntax
Schematron schema for plists
Running Schematron
JUnit test for Schematron Schema
XMLUnit
XMLUnit
A simple test case
But this is not just a String comparison!
Readers and Documents
Assertion messages
Concepts of Equality
Some documents that are equal but not identical
CDATA Handling is Broken
The Diff class
Testing for identity
XPath Based Tests
XPath Example
DifferenceListener
A DifferenceListener That Consider text nodes and CDATA sections to be equal
Comparing two documents with the custom DifferenceListener That Ignores Attributes
ElementQualifier
XMLUnit
To Learn More
Entire Presentation as Single File
Start
|
Cafe con Leche
Copyright 2005 Elliotte Rusty Harold
Last Modified June 6, 2005