runTests method

Future<bool> runTests(
  1. String fileName,
  2. bool record, [
  3. String outputPath = '/'
])

Implementation

Future<bool> runTests(String fileName, bool record,
    [String outputPath = '/']) async {
  var res = false;
  print('Will record video? $record');
  if (record) {
    var recordingProcess = await Process.start('xcrun', [
      'simctl',
      'io',
      _id,
      'recordVideo',
      p.join(outputPath, '${fileName.split("/").last.split(".").first}.mp4')
    ]);
    print('Executing flutter test');
    try {
      await runAsync('flutter', ['test', '-d', _id, '--pub', fileName]);
      recordingProcess.kill(ProcessSignal.sigint);

      return true;
    } on RuntimeException catch (e) {
      recordingProcess.kill(ProcessSignal.sigint);
      return false;
    }
  }
  print('Running flutter test');
  try {
    await runAsync('flutter', ['test', '-d', _id, '--pub', fileName]);
    return true;
  } on RuntimeException catch (e) {
    return false;
  }
}