Open oznecniV97 opened 6 months ago
Uh, I feel like the right thing to do here is just to make MockSpec
class final
. Why would anyone want to subclass it?
I need to extend MockSpec
to use a default fallbackGenerators
for every classes.
EG:
class GetxMockSpec<T> extends MockSpec<T> {
const GetxMockSpec() : super(
fallbackGenerators: const {
#onStart: fallbackGenerator,
}
);
}
Could be a wrapper function instead.
MockSpec<T> getxMockSpec<T>() => MockSpec<T>(fallbackGenerators: {#onStart: generator});
(and I really hope we'll be able to get rid of fallback generators in the next major version).
Can the wrapper function be used in an annotation?
Wrapper function can't be used inside annotation:
Methods can't be invoked in constant expressions.
Mockito generator fail using a custom superclass that extends MockSpec inside GenerateNiceMocks annotation.
Command:
dart run build_runner build
Error:The problem is related to
_mockTargetFromMockSpec
method inside lib/src/builder.dart file, because of superclass contains values inside(super)
field.E.g.: