File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes testing images and PDFs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "testing images and PDFs" Watch "testing images and PDFs" New topic
Author

testing images and PDFs

Thad Humphries
Greenhorn

Joined: Feb 04, 2011
Posts: 14

Do you have an advice on automated testing for images and PDFs? I must generate TIFF, JPEG, PDF, etc. by merging database records, text files, format files, and other images. All the JUnit testing I can think to are things like size, depth, and dpi, things that are done by the 3rd party libraries and not by me. I have to check my code's results manually: Is the right font used? Is the text or image correctly placed? Are things scaled correctly on the page? Any ideas or libraries for automating more of that would be appreciated.


"Hell hath no limits, nor is circumscrib'd In one self-place; but where we are is hell, And where hell is, there must we ever be" --Christopher Marlowe, Doctor Faustus (v, 121-24)
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Thad Humphries wrote:Do you have an advice on automated testing for images and PDFs? I must generate TIFF, JPEG, PDF, etc. by merging database records, text files, format files, and other images. All the JUnit testing I can think to are things like size, depth, and dpi, things that are done by the 3rd party libraries and not by me. I have to check my code's results manually: Is the right font used? Is the text or image correctly placed? Are things scaled correctly on the page? Any ideas or libraries for automating more of that would be appreciated.

What I'd look at doing would be to detect each aspect individually by, for example, looking for specific shapes in the resulting bitmap to detect the correct font being used and checking the position of a known image in the resulting bitmap. Some of these tests would make heavy use of image processing algorithms (which likely means you wouldn't implement them just for one or two tests' needs) and while some tests can be made simpler with smart setup (e.g. using a solid red image that's easy to look for in the resulting bitmap), these tests will certainly look and feel quite different from the kind of tests you'd write for typical application logic.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: testing images and PDFs