7.3.  A quick Look at PDFUnit-XML

It is unnecessary for testers to know Java to write tests for PDF documents. With the name 'PDFUnit-XML' a version of PDFUnit exists for an XML-based system. It contains a runtime to execute the tests, scripts to start them, XML Schema to validate the tests and stylesheets as part of the runtime. 'PDFUnit-XML' is completely compatible with 'PDFUnit-Java'.

The following examples show the idea behind PDFUnit-XML:

<testcase name="hasTextOnSpecifiedPages_Containing">
  <assertThat testDocument="content/diverseContentOnMultiplePages.pdf">
    <hasText onPage="1, 2, 3" >
      <containing>Content on</containing>
    </hasText>
  </assertThat>
</testcase>
<testcase name="hasTitle_MatchingRegex">
  <assertThat testDocument="documentInfo/documentInfo_allInfo.pdf">
    <hasTitle>
      <startingWith>PDFUnit sample</startingWith>
      <matchingRegex>.*Unit.*</matchingRegex>
    </hasTitle>
  </assertThat>
</testcase>
<testcase name="compareText_InPageRegion">
  <assertThat testDocument="test/test.pdf"
              referenceDocument="reference/reference.pdf"
  >
    <haveSameText on="EVERY_PAGE" >
      <inRegion upperLeftX="50" upperLeftY="720" width="150" height="30" />
    </haveSameText>
  </assertThat>
</testcase>
<testcase name="hasField_MultipleFields">
  <assertThat testDocument="acrofields/simpleRegistrationForm.pdf">
    <hasField withName="name" />
    <hasField withName="address" />
    <hasField withName="postal_code" />
    <hasField withName="email" />
  </assertThat>
</testcase>

Names of the tags and attributes are mostly the same as the function names in the Java-API. They also follow the idea of 'Fluent Interfaces' (http://de.wikipedia.org/wiki/Fluent_Interface).

XML Schema exists to validate the XML syntax.

A detailed description of PDFUnit-XML is available.