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

Bruno Cadonna commented on KAFKA-8977:
--------------------------------------

I agree with you that mocks are often just used to mock direct dependencies and 
verify their usage. However, mocks can also be used to just return values for 
the methods of the mocked object without any verification. That is also how 
`MockStreamsMetrics` is used at the moment, except that it uses production code 
to compute the return values. I would like to have mock that just returns 
constants. Maybe for some methods, we will need to provide some functionality 
to set the returned values during test setup. With this I would like to achieve 
a better isolation of unit tests. That is, I do not want that a unit test that 
uses `StreamsMetricsImpl` fails because there is a bug in `StreamsMetricsImpl`. 
Only the tests in `StreamsMetricsImplTest` should fail in that case. The goal 
is to reduce the maintenance costs of unit tests.

If you just want to remove {{MockStreamsMetrics}} with {{StreamsMetricsImpl}}, 
that is fine with me. IMO, this is already a step in the right direction.

> Remove MockStreamsMetrics Since it is not a Mock
> ------------------------------------------------
>
>                 Key: KAFKA-8977
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8977
>             Project: Kafka
>          Issue Type: Improvement
>          Components: streams
>            Reporter: Bruno Cadonna
>            Assignee: bibin sebastian
>            Priority: Minor
>              Labels: newbie
>
> The class {{MockStreamsMetrics}} is used throughout unit tests as a mock but 
> it is not really a mock since it only hides two parameters of the 
> {{StreamsMetricsImpl}} constructor. Either a real mock or the real 
> {{StreamsMetricsImpl}} should be used in the tests.



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

Reply via email to