AndrewJSchofield commented on PR #14879:
URL: https://github.com/apache/kafka/pull/14879#issuecomment-1836371437

   > > Can you elaborate on the direction to remove the background queue from 
the 'test builder' instead of using the one it constructed?
   > 
   > I had issues with tests using the spy on the `AsyncKafkaConsumer`. More 
precisely, a test failed with the spy but did not fail with a consumer not 
wrapped into a spy. BTW, IMO, spies (or partial mocks) should be used really 
carefully. Actually, good code does not need spies (with a few exceptions). 
Spies avoid to structure the code well. They do not force one to loosely couple 
objects. Even the [Mockito 
documentation](https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#spy)
 warns against their own spies. Additionally, the code under test, i.e., the 
async Kafka consumer, should not be wrapped into a spy. We should test that 
code directly to avoid possible side effects coming from the wrapping or from 
mistakes in specifying stubs on the spy.
   
   I've had exactly the same problem. Nested mocking makes it all very unhappy.


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to