[
https://issues.apache.org/jira/browse/HADOOP-14178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15944872#comment-15944872
]
Akira Ajisaka commented on HADOOP-14178:
----------------------------------------
Filed HADOOP-14245 for replacing Mockito.stub with Mockito.when.
For ArgumentMatcher, we need to fix the code when upgrading Mockito.
https://github.com/mockito/mockito/blob/v2.7.19/src/main/java/org/mockito/ArgumentMatcher.java#L88
{code}
* All existing custom implementations of <code>ArgumentMatcher</code> will no
longer compile.
* All locations where hamcrest matchers are passed to <code>argThat()</code>
will no longer compile.
* There are 2 approaches to fix the problems:
* <ul>
* <li>a) Refactor the hamcrest matcher to Mockito matcher:
* Use "implements ArgumentMatcher" instead of "extends ArgumentMatcher".
* Then refactor <code>describeTo()</code> method into <code>toString()</code>
method.
* </li>
* <li>
* b) Use <code>org.mockito.hamcrest.MockitoHamcrest.argThat()</code> instead
of <code>Mockito.argThat()</code>.
* Ensure that there is <a
href="http://hamcrest.org/JavaHamcrest/">hamcrest</a> dependency on classpath
* (Mockito does not depend on hamcrest any more).
{code}
I prefer option a) because it does not depend on hamcrest.
> Move Mockito up to version 2.x
> ------------------------------
>
> Key: HADOOP-14178
> URL: https://issues.apache.org/jira/browse/HADOOP-14178
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: test
> Affects Versions: 2.9.0
> Reporter: Steve Loughran
> Assignee: Akira Ajisaka
> Priority: Minor
>
> I don't know when Hadoop picked up Mockito, but it has been frozen at 1.8.5
> since the switch to maven in 2011.
> Mockito is now at version 2.1, [with lots of Java 8
> support|https://github.com/mockito/mockito/wiki/What%27s-new-in-Mockito-2].
> That' s not just defining actions as closures, but in supporting Optional
> types, mocking methods in interfaces, etc.
> It's only used for testing, and, *provided there aren't regressions*, cost of
> upgrade is low. The good news: test tools usually come with good test
> coverage. The bad: mockito does go deep into java bytecodes.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]