[ 
https://issues.apache.org/jira/browse/PDFBOX-5284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17420349#comment-17420349
 ] 

Xiao Wang commented on PDFBOX-5284:
-----------------------------------

Got it, thanks for your comments!

> Refactor PDFTabulaTextStripper to improve test design
> -----------------------------------------------------
>
>                 Key: PDFBOX-5284
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5284
>             Project: PDFBox
>          Issue Type: Improvement
>            Reporter: Xiao Wang
>            Priority: Minor
>
> h3. Description
> I noticed that there is a test class 
> [PDFTabulaTextStripper|https://github.com/apache/pdfbox/blob/588cb208653262ada43732a4e61c6fa3158f45f4/pdfbox/src/test/java/org/apache/pdfbox/text/TestTextStripper.java#L619]
>  extends production class 
> [PDFTextStripper|https://github.com/apache/pdfbox/blob/588cb208653262ada43732a4e61c6fa3158f45f4/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java#L61]
>  to assist testing  [PDFTextStripper.writeText(PDDocument, 
> Writer)|https://github.com/apache/pdfbox/blob/588cb208653262ada43732a4e61c6fa3158f45f4/pdfbox/src/main/java/org/apache/pdfbox/text/PDFTextStripper.java#L222].
>  This might not be the best priactice in unit testing and can be improved by 
> leveraging mocking frameworks.
> h3. Current Implementation
>  * {{PDFTabulaTextStripper}} overrides {{computeFontHeight(PDFont)}} to 
> control the behavior.
>  * {{PDFTabulaTextStripper}} overrides default constructor to make sure the 
> constructor do nothing.
> h3. Proposed Implementation
>  * Replace {{PDFTabulaTextStripper}} with a spying object created by Mockito.
>  * Use method stub to control the behavior of default constructor 
> {{computeFontHeight(PDFont)}}.
>  * Create a method to return the mocking object for reusing.
> h3. Motivation
>  * Decouple test class {{PDFTabulaTextStripper}} from production class 
> {{PDFTextStripper}}.
>  * Remove the redundant test child class {{PDFTabulaTextStripper}}
>  * Remove the redundant constructor.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to