runFailingAppTests function
Future<(List<String> , String)>
runFailingAppTests(
- GeneratedApp generated,
- MatrixApp app,
- List<
MatrixAppTest> tests, - List<
MatrixExpectedFailure> failures, { - MatrixFlutter flutter = _flutter,
- 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'),
);
}