This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new eeee8e206bc MINOR: Upgrade mockito test dependencies (#12460)
eeee8e206bc is described below
commit eeee8e206bcf105e68813812666268f796f0a379
Author: Dalibor Plavcic <[email protected]>
AuthorDate: Tue Aug 9 19:08:57 2022 +0200
MINOR: Upgrade mockito test dependencies (#12460)
## Changes
- **mockito: 4.4.0 -> 4.6.1** (https://github.com/mockito/mockito/releases)
Most important updates:
- Fixes https://github.com/mockito/mockito/issues/2648 : Add support for
customising strictness via @mock annotation and MockSettings
https://github.com/mockito/mockito/pull/2650
## Why is this change needed?
According to the [Mockito
documentation](https://javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/Mockito.html#when(T))
:
> Although it is possible to verify a stubbed invocation, usually it's just
redundant. Let's say you've stubbed foo.bar(). If your code cares what
foo.bar() returns then something else breaks(often before even verify() gets
executed). If your code doesn't care what get(0) returns then it should not be
stubbed.
While working on the [Replace EasyMock and PowerMock with Mockito for
StreamsMetricsImplTest ](https://issues.apache.org/jira/browse/KAFKA-12947) I
noticed that described behavior wasn't applied when you create a new `mock`
like this.
```java
final Metrics metrics = mock(Metrics.class);
when(metrics.metric(metricName)).thenReturn(null);
... invoke SUT
verify(metrics).metric(metricName); // this should be redundant
(according to docs)
```
After further investigation I figured out that described behaviour wasn't
implemented until`v4.6.1`.
With this change we are now able to mock objects like this:
```java
Foo explicitStrictMock = mock(Foo.class,
withSettings().strictness(Strictness.STRICT_STUBS));
```
- link to docs:
[MockSettings.html#strictness](https://javadoc.io/static/org.mockito/mockito-core/4.6.1/org/mockito/quality/Strictness.html#STRICT_STUBS)
It looks like I can accomplish the same thing by using the
`@RunWith(MockitoJUnitRunner.StrictStubs.class)
` instead of the `@RunWith(MockitoJUnitRunner.class)` so mockito dependency
version update is not mandatory, but it would be nice to stay up-to-date and
use the latest version (it's up to MR reviewer to decide if we are going to
merge this now, or just close the MR and update mockito version later).
Reviewers: Ismael Juma <[email protected]>
---
gradle/dependencies.gradle | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index 6c6b975ee9d..2a0220c1faa 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -104,7 +104,7 @@ versions += [
lz4: "1.8.0",
mavenArtifact: "3.8.4",
metrics: "2.2.0",
- mockito: "4.4.0",
+ mockito: "4.6.1",
netty: "4.1.78.Final",
powermock: "2.0.9",
reflections: "0.9.12",