diff --git a/CHANGELOG.md b/CHANGELOG.md index a6efc1b4..bbb99f67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 5.4.1-dev +## 5.4.1-wip * Deprecate the `mixingIn` argument to `MockSpec`. Best practice is to avoid any concrete implementation in classes which extend `Mock`. diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 45866fc8..b62fb17d 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -1380,15 +1380,7 @@ class _MockClassInfo { returnType.containsPrivateName || parametersContainPrivateName); - if (throwsUnsupported) { - if (!mockTarget.unsupportedMembers.contains(name)) { - // We shouldn't get here as this is guarded against in - // [_MockTargetGatherer._checkFunction]. - throw InvalidMockitoAnnotationException( - "Mockito cannot generate a valid override for '$name', as it has a " - 'non-nullable unknown return type or a private type in its ' - 'signature.'); - } + if (mockTarget.unsupportedMembers.contains(name)) { builder.body = refer('UnsupportedError') .call([ // Generate a raw string since name might contain a $. @@ -1400,6 +1392,14 @@ class _MockClassInfo { .code; return; } + if (throwsUnsupported) { + // We shouldn't get here as this is guarded against in + // [_MockTargetGatherer._checkFunction]. + throw InvalidMockitoAnnotationException( + "Mockito cannot generate a valid override for '$name', as it has a " + 'non-nullable unknown return type or a private type in its ' + 'signature.'); + } final invocation = referImported('Invocation', 'dart:core').property('method').call([ @@ -1881,14 +1881,7 @@ class _MockClassInfo { returnType is analyzer.TypeParameterType; final throwsUnsupported = fallbackGenerator == null && (returnTypeIsTypeVariable || getter.returnType.containsPrivateName); - if (throwsUnsupported) { - if (!mockTarget.unsupportedMembers.contains(getter.name)) { - // We shouldn't get here as this is guarded against in - // [_MockTargetGatherer._checkFunction]. - throw InvalidMockitoAnnotationException( - "Mockito cannot generate a valid override for '${getter.name}', as " - 'it has a non-nullable unknown type or a private type.'); - } + if (mockTarget.unsupportedMembers.contains(getter.name)) { builder.body = refer('UnsupportedError') .call([ // Generate a raw string since getter.name might contain a $. @@ -1901,6 +1894,13 @@ class _MockClassInfo { .code; return; } + if (throwsUnsupported) { + // We shouldn't get here as this is guarded against in + // [_MockTargetGatherer._checkFunction]. + throw InvalidMockitoAnnotationException( + "Mockito cannot generate a valid override for '${getter.name}', as " + 'it has a non-nullable unknown type or a private type.'); + } final invocation = referImported('Invocation', 'dart:core').property('getter').call([ diff --git a/lib/src/mock.dart b/lib/src/mock.dart index 58a9cdab..97bee48a 100644 --- a/lib/src/mock.dart +++ b/lib/src/mock.dart @@ -19,13 +19,12 @@ import 'dart:async'; +import 'package:matcher/expect.dart'; import 'package:meta/meta.dart'; import 'package:mockito/src/call_pair.dart'; import 'package:mockito/src/invocation_matcher.dart'; // ignore: deprecated_member_use import 'package:test_api/fake.dart'; -// ignore: deprecated_member_use -import 'package:test_api/test_api.dart'; /// Whether a [when] call is "in progress." /// diff --git a/lib/src/version.dart b/lib/src/version.dart index cac536c3..f346f259 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1 +1 @@ -const packageVersion = '5.4.1-dev'; +const packageVersion = '5.4.1-wip'; diff --git a/pubspec.yaml b/pubspec.yaml index 7fbabe6e..dbecddc4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: mockito -version: 5.4.1-dev +version: 5.4.1-wip description: >- A mock framework inspired by Mockito with APIs for Fakes, Mocks, behavior verification, and stubbing. @@ -18,7 +18,7 @@ dependencies: meta: ^1.3.0 path: ^1.8.0 source_gen: '>=0.9.6 <2.0.0' - test_api: '>=0.2.1 <0.6.0' + test_api: '>=0.2.1 <0.7.0' dev_dependencies: build_runner: ^2.0.0