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

Chris Egerton commented on KAFKA-14682:
---------------------------------------

[~divijvaidya] FYI, this may interest you.

> Unused stubbings are not reported by Mockito during CI builds
> -------------------------------------------------------------
>
>                 Key: KAFKA-14682
>                 URL: https://issues.apache.org/jira/browse/KAFKA-14682
>             Project: Kafka
>          Issue Type: Test
>          Components: unit tests
>            Reporter: Chris Egerton
>            Priority: Major
>
> We've started using [strict 
> stubbing|https://javadoc.io/static/org.mockito/mockito-core/4.6.1/org/mockito/junit/MockitoJUnitRunner.StrictStubs.html]
>  for unit tests written with Mockito, which is supposed to automatically fail 
> tests when they set up mock expectations that go unused.
> However, these failures are not reported during Jenkins builds, even if they 
> are reported when building/testing locally.
> In at least one case, this difference appears to be because our [Jenkins 
> build|https://github.com/apache/kafka/blob/6d11261d5deaca300e273bebe309f9e4f814f815/Jenkinsfile#L32-L35]
>  uses the custom {{unitTest}} and {{integrationTest}} tasks defined in the 
> project's [Gradle build 
> file|https://github.com/apache/kafka/blob/6d11261d5deaca300e273bebe309f9e4f814f815/build.gradle#L452-L543],
>  instead of the {{test}} task.
> It's possible that, because the custom test tasks filter out some tests from 
> running, Mockito does not check for unnecessary stubbings in order to avoid 
> incorrectly failing tests that set up mocks in, e.g., a {{@BeforeEach}} 
> method.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to