-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Is your feature request related to a problem? Please describe.
The current setup to provide the default data for the test driver via an annotations as 2 limitations.
- you are forced to use types which are
constas the default data. Since the annotation requires const input.
This could be an issue if you are not controlling the data type which your driver should return. And you cannot make it const.. - It makes the code a bit cluttery to define test values in the normal code..
Describe the solution you'd like
What if we could change a bit how you provide these default values.
What if you would just annotate all methods and properties which should have default values. Just like before.
But you do not provide the actualt default value here.
So something like this:
@generateTestDriver
class MyDriver extends WidgetDriver {
...
@provideTestDriverDefaultValue
bool get isDigitalKeyFirstEnabled => _featureToggleProvider.isDigitalKeyFirstEnabled();
...
}
And then further down in that file you create other data type which then defines the default values.
Then the default values are still in your prod code, but they are not defined directly in the code.
And you are also not restructed to using const values.. Since with an approach like this, you could just define any type you want.
So something like this
@generateTestDriver
class MyDriver extends WidgetDriver {
...
}
...
class _TestDriverDefaults implements TestDriverDefaults {
bool get isDigitalKeyFirstEnabled => false;
}
Additional context
I am not sure how this TestDriverDefaults setup should look like.. Either you need to annotate it also.
Or you inherit from some class or implement a specific interface.
But somehow I think this approach could work. I think the generator should be able to find all annotated properties in your driver and then try and map these to signature which it find ins the TestDriverDefaults.