From 09ecd089a4692f014439a99a594bdede7b623f9e Mon Sep 17 00:00:00 2001 From: oznecniV97 Date: Sun, 10 Dec 2023 19:20:46 +0100 Subject: [PATCH 1/5] add .idea folder to gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From 1603366a8a1f714c70bc1763df11c0a072a8b5a2 Mon Sep 17 00:00:00 2001 From: oznecniV97 Date: Sun, 10 Dec 2023 19:22:54 +0100 Subject: [PATCH 2/5] cycling on super field to fix inheritance bug --- lib/src/builder.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/src/builder.dart b/lib/src/builder.dart index 381b3a84..f31fb529 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(), + mockSpec, entryLib, index, mockSpecAsts, nice: true)); } From 1e7c03cc82779b27998592fa39a53628a0e8ab34 Mon Sep 17 00:00:00 2001 From: oznecniV97 Date: Thu, 21 Dec 2023 00:56:58 +0100 Subject: [PATCH 3/5] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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. From 1bb47bbf3f26549369f27f58f6874e41a6bdbbe9 Mon Sep 17 00:00:00 2001 From: oznecniV97 Date: Thu, 21 Dec 2023 00:57:17 +0100 Subject: [PATCH 4/5] Update pubspec.yaml --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 3e79325d1cb1e63e263d139d37fb22bdc6237e90 Mon Sep 17 00:00:00 2001 From: oznecniV97 Date: Thu, 21 Dec 2023 17:42:24 +0100 Subject: [PATCH 5/5] run dart format --- lib/src/builder.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/builder.dart b/lib/src/builder.dart index f31fb529..dbe9b572 100644 --- a/lib/src/builder.dart +++ b/lib/src/builder.dart @@ -575,7 +575,7 @@ class _MockTargetGatherer { 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") { + while (mockSpec.type?.element?.name != "MockSpec") { mockSpec = mockSpec.getField("(super)")!; } @@ -686,10 +686,10 @@ class _MockTargetGatherer { throw InvalidMockitoAnnotationException( 'The GenerateNiceMocks "mockSpecs" argument is missing'); } - final mockSpecAsts = _niceMocksAst(annotation.annotationAst).elements.toList(); + final mockSpecAsts = + _niceMocksAst(annotation.annotationAst).elements.toList(); return mockSpecsField.toListValue()!.mapIndexed((index, mockSpec) => - _mockTargetFromMockSpec( - mockSpec, entryLib, index, mockSpecAsts, + _mockTargetFromMockSpec(mockSpec, entryLib, index, mockSpecAsts, nice: true)); }