You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would love if we could specify a configuration (or more) per test
Description
As a developer, I would like to be able to only have to write a single goldenTest and be able to specify multiple configuration where the test would run.
For example:
goldenTest('foo', configuration: config1, ...);
I would expect that if the configuration parameter is not required the global configuration is used (if any) instead. Hence, once the test finishes the global configuration is restored. I would also expect, to be able to give the Configuration some kind of parameter in order if the null properties should be inherited.
The above is just an example. I'm not sure if it is to be considered the best API. Alternatives, could be, for example, to have a configurations be a List and avoid extracting the test method in order to reuse it. Or another possibility is to have a GoldenTestConfiguration widget:
I'm unsure if having logic within setUp and tearDown that alters the config (similar to the snippet below) would work; but if so, I think it feels very verbose in comparison with just providing the configuration to goldenTest.
In some scenarios, a developer would like to specify more than a single configuration. This could be motivated, for example, when there are different functionalities to be run when a given flavour or target is given. Hence, as a developer you would be interested on running the same test with different configurations.
Example 1
You have different themes for different platforms and you wish to have a config with each theme. Currently the flutter_test_config.dart file looks like the above snippet. This is similar to #21 .
This is similar to what I was trying to achieve. I'm testing button widgets that have an inverted state, which ideally means the theme is different for that specific GoldenTestGroup.
Looking at the code for goldenTest, it reaches out for the config directly using current:
final config =AlchemistConfig.current();
final currentPlatform =HostPlatform.current();
final variant =AlchemistTestVariant(
config: config,
currentPlatform: currentPlatform,
);
Unless I'm missing something from the wider context, this looks like it would be simple to implement for goldenTest for a single config.
Which property/ies on AlchemistConfig would you like to change per test? Could you achieve it using nested GoldenTestGroup and have a function generate a reusable "widget under test"?
Is there an existing feature request for this?
Command
I would love if we could specify a configuration (or more) per test
Description
As a developer, I would like to be able to only have to write a single goldenTest and be able to specify multiple configuration where the test would run.
For example:
I would expect that if the configuration parameter is not required the global configuration is used (if any) instead. Hence, once the test finishes the global configuration is restored. I would also expect, to be able to give the Configuration some kind of parameter in order if the null properties should be inherited.
The above is just an example. I'm not sure if it is to be considered the best API. Alternatives, could be, for example, to have a
configurations
be a List and avoid extracting the test method in order to reuse it. Or another possibility is to have aGoldenTestConfiguration
widget:--
I'm unsure if having logic within
setUp
andtearDown
that alters the config (similar to the snippet below) would work; but if so, I think it feels very verbose in comparison with just providing theconfiguration
togoldenTest
.Reasoning
In some scenarios, a developer would like to specify more than a single configuration. This could be motivated, for example, when there are different functionalities to be run when a given flavour or target is given. Hence, as a developer you would be interested on running the same test with different configurations.
Example 1
You have different themes for different platforms and you wish to have a config with each theme. Currently the
flutter_test_config.dart
file looks like the above snippet. This is similar to #21 .Additional context and comments
N/A
The text was updated successfully, but these errors were encountered: