Skip to content

codeborne/pdf-test

Repository files navigation

Maven Central Coverage Status

PDF Test

PDF testing library

Be sure that your code generates correct PDF!

How to use (Hamcrest)

import com.codeborne.pdftest.PDF; import static com.codeborne.pdftest.PDF.*; import static org.hamcrest.MatcherAssert.assertThat; public class PDFContainsTextTest { @Test public void canAssertThatPdfContainsText() { PDF pdf = new PDF(new File("src/test/resources/50quickideas.pdf")); assertThat(pdf, containsText("50 Quick Ideas to Improve your User Stories")); } }

How to use (AssertJ)

import com.codeborne.pdftest.PDF; import static com.codeborne.pdftest.assertj.Assertions.assertThat; public class PDFContainsTextTest { @Test public void canAssertThatPdfContainsText() { PDF pdf = new PDF(new File("src/test/resources/50quickideas.pdf")); assertThat(pdf).containsExactText("50 Quick Ideas to Improve your User Stories"); } @Test public void canUseSoftAssertions() { PDF pdf = new PDF(getClass().getClassLoader().getResource("minimal.pdf")); PdfSoftAssertions softly = new PdfSoftAssertions(); softly.assertThat(pdf).containsExactText("one"); softly.assertThat(pdf).containsExactText("two"); softly.assertThat(pdf).containsExactText("three"); softly.assertAll(); } }

How to start

If you use Maven, add the following dependency to pom.xml:

 <dependency> <groupId>com.codeborne</groupId> <artifactId>pdf-test</artifactId> <version>2.0.0</version> <scope>test</scope> </dependency>

If you use Gradle, add the following dependency to build.gradle:

 testImplementation 'com.codeborne:pdf-test:2.0.0'

How to contribute

You are welcome to suggest your features and fixes!

Just fork the pdf-test and create pull request. Any contribution is important!

** Become part of open-source community! **

Thanks

Many thanks to these incredible tools that help us to create open-source software:

Intellij IDEA

YourKit Java profiler

License

pdf-test is open-source project and distributed under MIT license

About

PDF Test

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6

Languages