Skip to content

Upgrading mockito 2 to 3

Breaking2.2.3 → 3.0.2Breaking1Changed3Other4

BreakingUpgrade verdict

1 breaking change.

  • The package now uses a newer analyzer API. If your code does resolution, you must update it to the new API.
1 item needs code or config changes

mockito publishes an official migration guide for version 3. It covers more than the release notes do.

Migration guide ↗

Dart SDK requirement changed in 3.0.1: >=2.0.0-dev.16.0 <2.0.0 → >=2.0.0 <3.0.0.

Breaking1
Switches to the new analyzer element2 APIs, requiring builders that do resolution to migrate.
element2

Generated by DepDelta from published Dart source. Not mixed with prose notes.

  • removed: class Mock
  • removed: class PostExpectation
  • removed: class VerificationResult
  • removed: ctor VerificationResult(this.callCount)
  • removed: field VerificationResult.callCount: int
  • removed: field VerificationResult.captured: List
  • removed: function argThat(Matcher matcher)
  • removed: function captureThat(Matcher matcher)
  • removed: function clearInteractions(var mock): void
  • removed: function logInvocations(List<Mock> mocks): void
  • removed: function named(var mock, {String name, int hashCode})
  • removed: function reset(var mock): void
  • removed: function resetMockitoState(): void
  • removed: function spy<E>(Mock mock, E spyOn): E
  • removed: function throwOnMissingStub(Mock mock): void
  • removed: function typed<T>(ArgMatcher matcher, {String named}): T
  • removed: function verifyNoMoreInteractions(var mock): void
  • removed: function verifyZeroInteractions(var mock): void
  • removed: get Mock.hashCode: int
  • removed: get any
  • removed: get captureAny
  • removed: get untilCalled: InvocationLoader
  • removed: get verify: Verification
  • removed: get verifyInOrder: _InOrderVerification
  • removed: get verifyNever: Verification
  • removed: get when: Expectation
  • removed: method Mock.noSuchMethod(Invocation invocation)
  • removed: method Mock.operator ==(other): bool
  • removed: method Mock.toString(): String
  • removed: method PostExpectation.thenAnswer(Answering answer)
  • removed: method PostExpectation.thenReturn(expected)
  • removed: method PostExpectation.thenThrow(throwable)
  • removed: method VerificationResult.called(matcher): void
  • removed: typedef Expectation = PostExpectation Function<T>(T x)
  • removed: typedef Verification = VerificationResult Function<T>(T matchingInvocations)
  • removed: typedef dynamic Answering(Invocation realInvocation)
  • removed: typedef dynamic Answering(Invocation realInvocation)
  • changed: class PostExpectation → class PostExpectation<T>
  • changed: field VerificationResult.captured: List → field VerificationResult.captured: List<dynamic>
  • changed: function argThat(Matcher matcher) → function argThat(Matcher matcher, {String named}): Null
  • changed: function captureThat(Matcher matcher) → function captureThat(Matcher matcher, {String named}): Null
  • changed: function named(var mock, {String name, int hashCode}) → function named<T extends Mock>(T mock, {String name, int hashCode}): T
  • changed: function typed<T>(ArgMatcher matcher, {String named}): T → function typed<T>(ArgMatcher matcher, {String named}): Null
  • changed: get any → get any: Null
  • changed: get captureAny → get captureAny: Null
  • changed: method Mock.noSuchMethod(Invocation invocation) → method Mock.noSuchMethod(Invocation invocation): dynamic
  • changed: method PostExpectation.thenAnswer(Answering answer) → method PostExpectation.thenAnswer(Answering<T> answer): void
  • changed: method PostExpectation.thenReturn(expected) → method PostExpectation.thenReturn(T expected): void
  • changed: method PostExpectation.thenThrow(throwable) → method PostExpectation.thenThrow(throwable): void
  • changed: typedef Expectation = PostExpectation Function<T>(T x) → typedef Expectation = PostExpectation<T> Function<T>(T x)
  • added: function anyNamed(String named): Null
  • added: function captureAnyNamed(String named): Null
  • added: function typedArgThat(Matcher matcher, {String named}): Null
  • added: function typedCaptureThat(Matcher matcher, {String named}): Null
  • added: typedef T Answering<T>(Invocation realInvocation)