testReader method

Future<List<PendingTest>?> testReader(
  1. BuildContext? context, {
  2. String? suiteName,
})

When running on a non-web platform this will read the tests from the file system using the testPath.

Implementation

Future<List<PendingTest>?> testReader(
  BuildContext? context, {
  String? suiteName,
}) async {
  var pendingTests = <PendingTest>[];

  if (kIsWeb) {
    _logger.warning(
      '[IoTestStore] -- testReader not supported on web',
    );
  } else {
    var path = testPath;

    if (suiteName != null) {
      path = '$path/$suiteName';
    }

    var files = Directory(path).listSync(recursive: true);

    for (var file in files) {
      try {
        if (file is File && file.path.endsWith('.json')) {
          var data = json.decode(file.readAsStringSync());

          var test = Test.fromDynamic(data);
          pendingTests.add(PendingTest.memory(test));
        }
      } catch (e) {
        // no-op
      }
    }
  }

  return pendingTests;
}