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

ASF GitHub Bot logged work on COLLECTIONS-798:
----------------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Feb/22 17:31
            Start Date: 08/Feb/22 17:31
    Worklog Time Spent: 10m 
      Work Description: Claudenw commented on pull request #278:
URL: 
https://github.com/apache/commons-collections/pull/278#issuecomment-1032875860


   I appreciate the effort to make the changes but the class under test is 
removed in the bloomfilter simplification code.


-- 
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: 723020)
    Time Spent: 20m  (was: 10m)

> Replace TestBuilder with mocking object to improve test design
> --------------------------------------------------------------
>
>                 Key: COLLECTIONS-798
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-798
>             Project: Commons Collections
>          Issue Type: Improvement
>            Reporter: Xiao Wang
>            Priority: Minor
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> h3. Description
> I noticed that there is a test class 
> [TestBuilder|https://github.com/apache/commons-collections/blob/3aae82cbaaaf539bf3f54cd6a0679efc123f2c8e/src/test/java/org/apache/commons/collections4/bloomfilter/hasher/HasherBuilderTest.java#L41]
>  implements production interface 
> [Builder|https://github.com/apache/commons-collections/blob/3aae82cbaaaf539bf3f54cd6a0679efc123f2c8e/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/DynamicHasher.java#L35]
>  to assist testing methd [Builder:with(CharacterSequence, 
> Charset)|https://github.com/apache/commons-collections/blob/3aae82cbaaaf539bf3f54cd6a0679efc123f2c8e/src/main/java/org/apache/commons/collections4/bloomfilter/hasher/DynamicHasher.java#L73].
>  This might not be the best priactice in unit testing and can be improved by 
> leveraging mocking frameworks.
> h3. Current Implementation
> *  {{TestBuilder}} implements {{Builder}} and creates a new list {{items}} to 
> keep tracking of the input parameters for {{with(byte[])}}.
> * In test cases, after executing test target, the list will be used in 
> assertion statement to check the input parameters of {{with(byte[])}}.
> h3. Proposed Implementation
>  * Replace {{TestBuilder}} with a mocking object created by Mockito.
>  * Extract the attribute into test cases to keep tracking input parameters.
>  * Use method stub to control the behavior of the mocking object.
> h3. Motivation
>  * Decouple test class {{TestBuilder}} from production interface {{Builder}}.
>  * Make test logic more clear by using method stub instead of method 
> overriding.
>  * Make test condition more explict by use local variable in test case.



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

Reply via email to