[
https://issues.apache.org/jira/browse/AVRO-3211?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Martin Tzvetanov Grigorov updated AVRO-3211:
--------------------------------------------
Summary: Drop PrintingVisitor since it does not bring much value (was:
Refactor PrintingVisitor to improve test design)
> Drop PrintingVisitor since it does not bring much value
> -------------------------------------------------------
>
> Key: AVRO-3211
> URL: https://issues.apache.org/jira/browse/AVRO-3211
> Project: Apache Avro
> Issue Type: Improvement
> Reporter: Xiao Wang
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.11.0
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> h3. Description
> I noticed that there is a test class
> [PrintingVisitor|https://github.com/apache/avro/blob/42822886c28ea74a744abb7e7a80a942c540faa5/lang/java/compiler/src/test/java/org/apache/avro/compiler/schema/TestSchemas.java#L41]
> implements production interface
> [SchemaVisitor|https://github.com/apache/avro/blob/42822886c28ea74a744abb7e7a80a942c540faa5/lang/java/compiler/src/main/java/org/apache/avro/compiler/schema/SchemaVisitor.java#L22]
> to assist testing
> [CloningVisitor|https://github.com/apache/avro/blob/42822886c28ea74a744abb7e7a80a942c540faa5/lang/java/compiler/src/main/java/org/apache/avro/compiler/schema/CloningVisitor.java#L33].
> This might not be the best priactice in unit testing and can be improved by
> leveraging mocking frameworks.
> h3. Current Implementation
> * {{PrintingVisitor}} implements {{SchemaVisitor}} and implements methods.
> * In test case, the child test class is used to assit testing by logging out
> method excution information.
> h3. Proposed Implementation
> * Replace {{PrintingVisitor}} with a mocking object created by Mockito.
> * Use method stub to control the behavior of the mocking object and logging
> information.
> * Create a method to return the mocking object for reusing.
> h3. Motivation
> * Decouple test class {{PrintingVisitor}} from production interface
> {{SchemaVisitor}}.
> * Remove the redundant test child class {{PrintingVisitor}}
> h3. More Thought
> * If we only use {{PrintingVisitor}} to log out information, we can actually
> get rid of PrintingVisitor and spy CloningVisitor, then use Mockito.verify()
> to verify method execution times and order based on the given Schema.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)