[ 
https://issues.apache.org/jira/browse/CURATOR-610?focusedWorklogId=635822&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-635822
 ]

ASF GitHub Bot logged work on CURATOR-610:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Aug/21 10:07
            Start Date: 09/Aug/21 10:07
    Worklog Time Spent: 10m 
      Work Description: eolivelli commented on pull request #397:
URL: https://github.com/apache/curator/pull/397#issuecomment-895101708


   LGTM
   I will merge as soon as CI is green


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 635822)
    Time Spent: 1h  (was: 50m)

> Refactor CountCuratorWatcher in TestWatcherIdentity.java to improve test logic
> ------------------------------------------------------------------------------
>
>                 Key: CURATOR-610
>                 URL: https://issues.apache.org/jira/browse/CURATOR-610
>             Project: Apache Curator
>          Issue Type: Improvement
>          Components: Framework
>            Reporter: Xiao Wang
>            Priority: Minor
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> h3. Description
> I noticed that there is a test class 
> [CountCuratorWatcher|https://github.com/apache/curator/blob/4a11aaef8b190dc220d35b7a91df294bfa06250e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherIdentity.java#L42]
>  implements production interface 
> [curatorWatcher|https://github.com/apache/curator/blob/4a11aaef8b190dc220d35b7a91df294bfa06250e/curator-framework/src/main/java/org/apache/curator/framework/api/CuratorWatcher.java#L27]
>  to assist testing production class 
> [CuratorFrameworkImpl|https://github.com/apache/curator/blob/4a11aaef8b190dc220d35b7a91df294bfa06250e/curator-framework/src/main/java/org/apache/curator/framework/imps/CuratorFrameworkImpl.java#L66].
>  This might not be the best priactice in unit testing and can be improved by 
> leveraging mocking frameworks.
> h3. Current Implementation
> *  {{CountCuratorWatcher}} implements {{CuratorWatcher}} and creates a new 
> variable to keep tracking of the method invocation status for 
> {{process(WatchedEvent)}}.
> * In test cases, after executing test target, the new variable will be used 
> in assertion statement to check the execution status of 
> {{process(WatchedEvent)}}.
> h3. Proposed Implementation
>  * Replace {{CountCuratorWatcher}} with a mocking object created by Mockito.
>  * Extract the AtomicLong attribute and use the extracted attribute to check 
> method invocation status.
>  * Use method stub to control the behavior of the mocking object.
> h3. Motivation
>  - Decouple test class `CountCuratorWatcher` from production interface 
> `CuratorWatcher`.
>  - Make test logic more clear by using method stub instead of method 
> overriding.



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

Reply via email to