runFailingAppTests function

Future<(List<String>, String)> runFailingAppTests(
  1. GeneratedApp generated,
  2. MatrixApp app,
  3. List<MatrixAppTest> tests,
  4. List<MatrixExpectedFailure> failures, {
  5. MatrixFlutter flutter = _flutter,
  6. FileSystem fileSystem = const LocalFileSystem(),
})

Adds tests to generated, the app of the matrix app, with their dev dependencies, and runs them with flutter test --reporter json through flutter once the app with the tests passes flutter analyze: the tests of failures must fail as they expect, and the other tests of the app must pass (see expectedFailureProblems).

Returns the problems, and the output with a line for each test that ran (see testRunSummary). When a command before the tests fails, or the files of the tests have a problem, the problem is the last line of the output, and no test runs.

Implementation

Future<(List<String>, String)> runFailingAppTests(
  GeneratedApp generated,
  MatrixApp app,
  List<MatrixAppTest> tests,
  List<MatrixExpectedFailure> failures, {
  MatrixFlutter flutter = _flutter,
  FileSystem fileSystem = const LocalFileSystem(),
}) async {
  final (code, output) = await _addAndRun(
    generated,
    app,
    tests,
    [
      ..._pubAdd(tests),
      const ['analyze'],
    ],
    flutter: flutter,
    fileSystem: fileSystem,
  );
  if (code != 0) return ([output.trim().split('\n').last], output);
  final (_, report) = await flutter(
    const ['test', '--reporter', 'json'],
    generated.path,
  );
  final summary = testRunSummary(report, directory: generated.path);
  return (
    expectedFailureProblems(report, failures, directory: generated.path),
    [output, ...summary].join('\n'),
  );
}