You can use the i-net PDFC Server to compare PDF files in your JUnit tests on any computer in your network. This can be your continuous integration server or from the IDE of the developers.
Before you can start with JUnit testing you need:
In your test enviroment you need to add the needed dependencies.
<dependencies> <dependency org="de.inetsoftware" name="pdfcjunit" rev="4.+"/> <dependency org="junit" name="junit" rev="4.12"/> <dependency org="javax.websocket" name="javax.websocket-api" rev="1.1"/> <dependency org="org.glassfish.tyrus" name="tyrus-container-jdk-client" rev="1.+"/> </dependencies>
repositories { jcenter() } dependencies { testCompile 'de.inetsoftware:pdfcjunit:4.+' testCompile 'junit:junit:4.12' testCompile 'javax.websocket:javax.websocket-api:1.1' testCompile 'org.glassfish.tyrus:tyrus-container-jdk-client:1.+' }
import static com.inet.pdfc.junit.PdfcAssert.*; import org.junit.*; public class PdfcTest { @BeforeClass public static void beforeClass() { // If you search for problems then you can enable the logging // PdfcAssert.setLogLevel( com.inet.logging.Logger.DEBUG ); // if you have more as one i-net PDFC Server // or if the server can not be found via broadcast // setServicePath( "myhost:9900" ); // if the current windows user has no access to the server // setCredentials( "user", "password" ); } @Test public void myTest() { // compare if both files are equals assertPdfEquals( "file1.pdf", "file2.pdf" ); } }