init build flavor capability
This commit is contained in:
parent
ee74945d95
commit
5aa50920b4
|
@ -20,6 +20,7 @@ Future<void> main() {
|
|||
..customStepParameterDefinitions = [ColourParameter()]
|
||||
..restartAppBetweenScenarios = true
|
||||
..targetAppPath = "test_driver/app.dart"
|
||||
// ..buildFlavor = "staging" // uncomment when using build flavor
|
||||
// ..tagExpression = "@smoke" // uncomment to see an example of running scenarios based on tag expressions
|
||||
..exitAfterTestRun = true; // set to false if debugging to exit cleanly
|
||||
return GherkinRunner().execute(config);
|
||||
|
|
|
@ -19,6 +19,7 @@ class FlutterRunProcessHandler extends ProcessHandler {
|
|||
List<StreamSubscription> _openSubscriptions = <StreamSubscription>[];
|
||||
String _appTarget;
|
||||
String _workingDirectory;
|
||||
String _buildFlavor;
|
||||
|
||||
void setApplicationTargetFile(String targetPath) {
|
||||
_appTarget = targetPath;
|
||||
|
@ -28,10 +29,16 @@ class FlutterRunProcessHandler extends ProcessHandler {
|
|||
_workingDirectory = workingDirectory;
|
||||
}
|
||||
|
||||
void setBuildFlavor(String buildFlavor) {
|
||||
_buildFlavor = buildFlavor;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> run() async {
|
||||
final buildFlavorArg =
|
||||
_buildFlavor.isNotEmpty ? "--flavor=$_buildFlavor" : "";
|
||||
_runningProcess = await Process.start(
|
||||
"flutter", ["run", "--target=$_appTarget"],
|
||||
"flutter", ["run", "--target=$_appTarget", buildFlavorArg],
|
||||
workingDirectory: _workingDirectory, runInShell: true);
|
||||
_processStdoutStream =
|
||||
_runningProcess.stdout.transform(utf8.decoder).asBroadcastStream();
|
||||
|
|
|
@ -22,6 +22,10 @@ class FlutterTestConfiguration extends TestConfiguration {
|
|||
/// Defaults to "lib/test_driver/app.dart"
|
||||
String targetAppPath = "lib/test_driver/app.dart";
|
||||
|
||||
/// The build flavor to run the tests against
|
||||
/// Defaults to empty
|
||||
String buildFlavor = "";
|
||||
|
||||
void setObservatoryDebuggerUri(String uri) => _observatoryDebuggerUri = uri;
|
||||
|
||||
Future<FlutterDriver> createFlutterDriver([String dartVmServiceUrl]) async {
|
||||
|
|
|
@ -44,6 +44,7 @@ class FlutterAppRunnerHook extends Hook {
|
|||
Future<void> _runApp(FlutterTestConfiguration config) async {
|
||||
_flutterAppProcess = FlutterRunProcessHandler();
|
||||
_flutterAppProcess.setApplicationTargetFile(config.targetAppPath);
|
||||
_flutterAppProcess.setBuildFlavor(config.buildFlavor);
|
||||
stdout.writeln(
|
||||
"Starting Flutter app under test '${config.targetAppPath}', this might take a few moments");
|
||||
await _flutterAppProcess.run();
|
||||
|
|
Loading…
Reference in New Issue