runTests method
Runs a series of tests
. This is useful for smaller numbers of in-memory
tests but the runPendingTests should be prefered for full application
runs or for CI/CD pipelines as that only loads the bare minimum data up
front and then loads the full test data on an as needed basis.
Implementation
Future<TestSuiteReport> runTests(
List<Test> tests, {
Duration? stepTimeout,
Duration waitTimeout = _kSuiteStartTimeout,
}) async {
final startTime = DateTime.now();
while (_testControllerState.runningSuite == true) {
if (DateTime.now().millisecondsSinceEpoch -
startTime.millisecondsSinceEpoch >=
waitTimeout.inMilliseconds) {
throw Exception(
'[TIMEOUT]: Could not start tests, suite is still running.',
);
}
await Future.delayed(const Duration(milliseconds: 100));
}
final testSuiteReport = TestSuiteReport();
_testControllerState.runningSuite = true;
if (tests.isNotEmpty == true) {
try {
for (var test in tests) {
try {
await reset();
await execute(
name: test.name,
reset: false,
stepTimeout: stepTimeout,
steps: test.steps,
submitReport: true,
suiteName: test.suiteName,
testSuiteReport: testSuiteReport,
version: test.version,
);
} catch (e, stack) {
_logger.severe(e, stack);
}
}
} finally {
_testControllerState.runningSuite = false;
}
await _navigatorKey?.currentState?.push(
MaterialPageRoute(
builder: _testSuiteReportBuilder ??
((BuildContext context) => TestSuiteReportPage()),
settings: RouteSettings(
arguments: testSuiteReport,
),
),
);
}
return testSuiteReport;
}