C0urante commented on PR #11792: URL: https://github.com/apache/kafka/pull/11792#issuecomment-1259557319
@divijvaidya I've also used the `OngoingStubbing` class to set up multiple expectations for a mock at once. I'm not sure if it's applicable to your case, but I found that it wasn't too painful to create a utility method that accepts and returns an `OngoingStubbing` in cases where the logic was too complicated to repeat each time. See [here](https://github.com/C0urante/kafka/blob/2b44825bd1141e17474225d76246129229a9bca6/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ExactlyOnceWorkerSourceTaskTest.java#L742-L748) and [here](https://github.com/C0urante/kafka/blob/2b44825bd1141e17474225d76246129229a9bca6/connect/runtime/src/test/java/org/apache/kafka/connect/runtime/ExactlyOnceWorkerSourceTaskTest.java#L908-L926) for an example of that approach. It's also worth noting that, due to the interleaving of setting up mock expectations with actually executing test code, often times it's not actually necessary to establish multiple expectations on a single mock when using Mockito. There are exceptions for this, of course, but otherwise, it's usually better to set a single expectation, run some test code, set a new expectation, etc. instead of setting up everything all at once (which is necessary with EasyMock/PowerMock). -- 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