Skip to content

Commit

Permalink
Remove all deprecated APIs (#2418)
Browse files Browse the repository at this point in the history
All of these APIs have been marked as deprecated and have been present
in Mockito for quite a while. To cleanup our API surface and reduce
technical debt, let's remove these long-deprecated methods/classes.

An overview of now-deleted classes/methods:
- org.mockito.Matchers which was an alias for
org.mockito.ArgumentMatchers
- org.mockito.ArgumentMatchers#{anyObject,anyVararg} both which were
aliases for org.mockito.ArgumentMatchers#any
- org.mockito.ArgumentMatchers#any*Of, which were aliases for the same
method name without the Of and the generic parameters (which were
ignored)
- org.mockito.ArgumentMatchers#{is}{Not}Null(Class) which took a class
which was ignored. Aliases for the same methods without the parameter
- org.mockito.MockedStatic#verify which had the parameter types reversed
- org.mockito.Mockito#verifyZeroInteractions an alias of
verifyNoMoreInteractions
- org.mockito.Mockito#debug framework integration API that we later
refactored
- org.mockito.configuration.AnnotationEngine which was leaking internal
APIs and instead users should use org.mockito.plugins.AnnotationEngine
- org.mockito.exceptions.verification.TooLittleActualInvocations fixed
the grammar from "Little" to "Few"
- Numerous internal APIs that we never officially supported and can now
be removed
- org.mockito.plugins.InstantiatorProvider which was leaking internal
APIs and instead users should use InstantiatorProvider2 (we should
probably rename back to remove the number in a future major release)
- org.mockito.runners a package that hosted several old JUnit runners
which were no longer supported. Users should instead use
org.mockito.junit.MockitoJUnitRunner which is our official JUnit4
runner.

Since these APIs are removed, this change effectively defines Mockito 4.
  • Loading branch information
TimvdLippe committed Sep 9, 2021
1 parent 916e61e commit caf35b2
Show file tree
Hide file tree
Showing 109 changed files with 158 additions and 2,317 deletions.
3 changes: 1 addition & 2 deletions settings.gradle.kts
Expand Up @@ -2,8 +2,7 @@ plugins {
id("com.gradle.enterprise").version("3.3.4")
}

include("deprecatedPluginsTest",
"inline",
include("inline",
"proxy",
"extTest",
"groovyTest",
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/mockito/AdditionalMatchers.java
Expand Up @@ -16,11 +16,11 @@
import org.mockito.internal.matchers.LessThan;

/**
* See {@link Matchers} for general info about matchers.
* See {@link ArgumentMatchers} for general info about matchers.
* <p>
* AdditionalMatchers provides rarely used matchers, kept only for somewhat compatibility with EasyMock.
* Use additional matchers very judiciously because they may impact readability of a test.
* It is recommended to use matchers from {@link Matchers} and keep stubbing and verification simple.
* It is recommended to use matchers from {@link ArgumentMatchers} and keep stubbing and verification simple.
* <p>
* Example of using logical and(), not(), or() matchers:
*
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/org/mockito/Answers.java
Expand Up @@ -85,15 +85,6 @@ public enum Answers implements Answer<Object> {
this.implementation = implementation;
}

/**
* @deprecated as of 2.1.0 Use the enum-constant directly, instead of this getter. This method will be removed in a future release<br>
* E.g. instead of <code>Answers.CALLS_REAL_METHODS.get()</code> use <code>Answers.CALLS_REAL_METHODS</code> .
*/
@Deprecated
public Answer<Object> get() {
return this;
}

@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return implementation.answer(invocation);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/mockito/ArgumentMatcher.java
Expand Up @@ -44,7 +44,7 @@
* </ul>
*
* <p>
* Implementations of this interface can be used with {@link Matchers#argThat} method.
* Implementations of this interface can be used with {@link ArgumentMatchers#argThat} method.
* Use <code>toString()</code> method for description of the matcher
* - it is printed in verification errors.
*
Expand Down Expand Up @@ -84,7 +84,7 @@
* </code></pre>
*
* <p>
* Read more about other matchers in javadoc for {@link Matchers} class.
* Read more about other matchers in javadoc for {@link ArgumentMatchers} class.
* <h2>2.1.0 migration guide</h2>
*
* All existing custom implementations of <code>ArgumentMatcher</code> will no longer compile.
Expand Down

0 comments on commit caf35b2

Please sign in to comment.