[ 
https://issues.apache.org/jira/browse/JCR-4710?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Reschke resolved JCR-4710.
---------------------------------
    Resolution: Not A Problem

> Refactor DummyInternalVersion in VersionIteratorImplTest.java to improve test 
> logic
> -----------------------------------------------------------------------------------
>
>                 Key: JCR-4710
>                 URL: https://issues.apache.org/jira/browse/JCR-4710
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-core
>            Reporter: Xiao Wang
>            Priority: Minor
>              Labels: Refactoring, Test
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> h3. Description
> I noticed that there is a test class 
> [DummyInternalVersion|https://github.com/apache/jackrabbit/blob/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java#L32]
>  implements a production interface 
> [InternalVersion|https://github.com/apache/jackrabbit/blob/6ed753e4dc30b70fd2ba03ba1977e5d63c8d85dc/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersion.java#L29]
>  to assist testing production constructor 
> [VersionIteratorImpl::VersionIteratorImpl(Session, 
> InternalVersion)|https://github.com/apache/jackrabbit/blob/6ed753e4dc30b70fd2ba03ba1977e5d63c8d85dc/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionIteratorImpl.java#L70].
>  This might not be the best priactice in unit testing and can be improved by 
> leveraging mocking frameworks.
> h3. Current Implementation
>  * {{DummyInternalVersion}} implements {{InternalVersion}}, creates two 
> variables id and successors to control the behavior of method {{getId()}} and 
> {{getSuccessors()}}.
>  * Impelements other redundant methods and make them return null.
> h3. Proposed Implementation
>  * Replace {{DummyInternalVersion}} with a mocking object created by Mockito.
>  * Use method stub to control the behavior of {{getId()}} and 
> {{getSuccessors()}} in the mocking object.
>  * Ignore the redundant methods to make test logic more clear.
>  * Create a method to return the mocking object for reuse purpose.
> h3. Motivation
>  * Decoupling test class {{DummyInternalVersion}} from production interface 
> {{InternalVersion}}.
>  * Making test condition more clear by removing all redundant overridden 
> methods.
>  * Making test logic more clear by using method stub instead of method 
> overriding.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to