Skip to content

kiu345/docunit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocUnit

A fluent assertion library for testing document content in JUnit test cases, designed for structured formats like PDF, XML, Word and Excel.

Right now is’s more or less a quick hack, for basic usage see the JUnit test files.

1. Features

  • Fluent assertions on binary document content (byte arrays, input streams)

  • Supported formats:

    • Text

      • CSV

      • JSON

      • XML

    • Word (DOCX)

    • Excel (XLSX)

    • PDF

    • Images

      • PNG

      • JPEG

      • GIF

    • ZIP

2. Example Usage

assertDoc(pdfBytes)
    .asPDF()
    .hasText("Bill")
    .hasPageCount(1);

assertDoc(imageBytes)
    .asJpeg()
    .hasImageSize(100, 100);
    .hasCaption("Testimage")
    .hasAverageRgbDeltaLessThan(image2Bytes, 3.0);

assertDoc(xmlBytes)
    .asXml()
    .hasXPath("//total", "100.00")
    .hasRootElement("invoice");

assertDoc(jsonBytes)
    .asJSON()
    .hasValue("$.user.id", "42");
Warning
alpha/wip/poc code

3. Planned

  • more checks

  • more formats

About

Java binary document unit test asserts in the style of AssertJ

Topics

Resources

License

Stars

Watchers

Forks