11.3.  Running PDFUnit-XML

The fundamentals of Running PDFUnit-XML

The ANT script PDFUNITXML_HOME/build.xml starts your PDFUnit-XML tests. The script requires that Java and ANT are installed and can be found. All configurations are done in this script.

If you want to change the file build.xml, make sure that the classpath contains the directory PDFUNITJAVA_HOME. The file config.properties is searched on the classpath.

Running PDFUnit-XML from a Shell

Open a shell. (Depending on your operating system you might call it command prompt, DOS box or command line.) Go to your project directory PROJECT_HOME and enter the command:

ant all

or:

runPDFUnit.bat

The scripts runPDFUnit.bat and runPDFUnit.sh call ANT and allow you to configure the pathes to your Java and ANT installations.

Assuming Java and ANT are installed and registered in the operating system's path, a detailed log can be seen during execution of the ANT script:

Buildfile: C:\pdfunit-xml_demo\build.xml

clean:
     [delete] Deleting directory C:\pdfunit-xml_demo\build_ant

00_resolveDTD:
     [echo] start resolving DTD entities ...
     [mkdir] Created dir: C:\pdfunit-xml_demo\build_ant\xml
     [xslt] Loading stylesheet C:\pdfunit-xml_demo\lib\pdfunit-xml-2015.10\xslt\...
     [xslt] Processing C:\pdfunit-xml_demo\src\test\xml\CompareTestDemo.xml 
      ...
     [echo] ... finished
     
     ...
     ...

01_verifyXML:
     [echo] start validating PDFUnit test files (xml) ...
     [copy] Copying 1 file to C:\pdfunit-xml_demo\build_ant\xsd
     [echo] ... finished

02_generateJavaSourcesFromXML:
     [echo] start transforming PDFUnit test files (xml) into Java code ...
     [mkdir] Created dir: C:\pdfunit-xml_demo\build_ant\java\org\pdfunit\xml
     [xslt] Loading stylesheet C:\pdfunit-xml_demo\lib\pdfunit-xml-2015.10\xslt\...
     [xslt] Processing C:\pdfunit-xml_demo\src\test\xml\CompareTestDemo.xml 
      ...
     [echo] ... finished
     
     ...
     ...

03_compileGeneratedSources:
     [echo] start compiling generated sources ...
     [mkdir] Created dir: C:\pdfunit-xml_demo\build_ant\classes
     [javac] Compiling 9 source files to C:\pdfunit-xml_demo\build_ant\classes
     [echo] ... finished

04_runUnittest:
     [echo] start running unit tests from compiled sources ...
     [mkdir] Created dir: C:\pdfunit-xml_demo\build_ant\junit\data
     [junit] Running org.pdfunit.xml.ContentTestDemo
     [junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 1.054 sec
      ...
     [echo] ... finished

-testreport:
     [echo] start creating HTML report from unit test result ...
     [mkdir] Created dir: C:\pdfunit-xml_demo\build_ant\junit\html
     [junitreport] Processing C:\pdfunit-xml_demo\build_ant\junit\html\...
     [junitreport] Loading stylesheet JAR:file:/C:/environment/share32/tools/...
     [junitreport] Transform time: 890ms
     [junitreport] Deleting: c:\Temp\null1904905169
     [echo] ... finished
     [echo] Please look for index.html in subfolder build_ant/junit/html

all:

BUILD SUCCESSFUL

The script creates a detailed HTML report for all tests. It is be found in the folder PROJECT_HOME/build_ant/junit/html/index.html. Here's a look at the report of the demo project included in the installation ZIP file you downloaded:

Overview of the Test Report

If you forget to copy the PDFUnit-Java libraries into the directory PROJECT_HOME/lib/pdfunit-java_VERSION, the following error message appears:

[javac]   ... error: cannot find symbol
[javac]     AssertThat.document(filename)
[javac]     ^
[javac]   symbol:   variable AssertThat

Using PDFUnit-XML in IDE's

You prefere to start PDFUnit-XML from an IDE like Eclipse? You can, simply start the ANT script PROJECT_HOME/build.xml from within the IDE. If you need help, write to us at support[at]pdfunit.com.