diff --git a/.gitignore b/.gitignore index b3bfe992..67f62b60 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,7 @@ build/ coverage/ # ignore generated mocks -**/*.mocks.dart \ No newline at end of file +**/*.mocks.dart + +# ide folders +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md index 55253622..83dfa5c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.4.5-wip + +* Allow usage of GetMock superclasses. + ## 5.4.4 * Use `posix` style for local imports. diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 381b3a84..dbe9b572 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -574,6 +574,11 @@ class _MockTargetGatherer { int index, List mockSpecAsts, {bool nice = false}) { + // need to get the parent until type name is not MockSpec to allow inheritance + while (mockSpec.type?.element?.name != "MockSpec") { + mockSpec = mockSpec.getField("(super)")!; + } + final mockSpecType = mockSpec.type as analyzer.InterfaceType; assert(mockSpecType.typeArguments.length == 1); final mockType = _mockType(mockSpecAsts[index]); @@ -681,10 +686,10 @@ class _MockTargetGatherer { throw InvalidMockitoAnnotationException( 'The GenerateNiceMocks "mockSpecs" argument is missing'); } - final mockSpecAsts = _niceMocksAst(annotation.annotationAst).elements; + final mockSpecAsts = + _niceMocksAst(annotation.annotationAst).elements.toList(); return mockSpecsField.toListValue()!.mapIndexed((index, mockSpec) => - _mockTargetFromMockSpec( - mockSpec, entryLib, index, mockSpecAsts.toList(), + _mockTargetFromMockSpec(mockSpec, entryLib, index, mockSpecAsts, nice: true)); } diff --git a/pubspec.yaml b/pubspec.yaml index e5585b58..0d4894e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: mockito -version: 5.4.4 +version: 5.4.5-wip description: >- A mock framework inspired by Mockito with APIs for Fakes, Mocks, behavior verification, and stubbing.