The first and simplest test is to check that a document has the same number of form fields as the master document:
<testcase name="haveSameNumberOfFields"> <assertThat testDocument="test/test.pdf" masterDocument="master/master.pdf" > <haveSameNumberOfFields /> </assertThat> </testcase>
The next test checks that the number of fields and their names are equal in both PDF documents:
<testcase name="haveSameFields_ByName"> <assertThat testDocument="test/test.pdf" masterDocument="master/master.pdf" > <haveSameFields by="NAME" /> </assertThat> </testcase>
If you want to compare the fields of two documents including all properties
you have to use the tag <haveSameFields />
with
the attribute by="PROPERTIES"
:
<testcase name="haveSameFields_ByProperties"> <assertThat testDocument="test/test.pdf" masterDocument="master/master.pdf" > <haveSameFields by="PROPERTIES" /> </assertThat> </testcase>
All field properties can be extracted into an XML file using the utility
program ExtractFieldsInfo
, see chapter
9.3: “Extract Field Information to XML”.
This file can be analyzed later.
And finally you can compare the content of form fields of
two documents using the tag <haveSameFields />
and the attribute by="VALUE"
.
The test fails when a field have different contents in the two files:
<testcase name="haveSameFields_ByValues"> <assertThat testDocument="test/test.pdf" masterDocument="master/master.pdf" > <haveSameFields by="VALUE" /> </assertThat> </testcase>
Whitespaces are “normalized”, see chapter 13.4: “Whitespace Processing”. |
You can compare fields and other parts of two PDF documents in one test, but such a test is not recommended because it's hard to find a good name:
<testcase name="compareManyItems"> <assertThat testDocument="test/test.pdf" masterDocument="master/master.pdf" > <haveSameFields by="PROPERTIES" /> <haveSameFields by="VALUE" /> <haveSameFonts /> <haveSameTitle /> <haveSameAuthor /> </assertThat> </testcase>