parseFile static method
Loads a test file from rootBundle (widget/integration tests) or File (CLI).
Implementation
static Future<EnsembleTestCase> parseFile(String path) async {
Object? bundleError;
try {
final content = await rootBundle.loadString(path);
return parseString(content, sourcePath: path);
} catch (error) {
bundleError = error;
}
// dart:io can hang under widget test bindings' fake async zone.
if (_isWidgetTestBinding) {
throw EnsembleTestFailure(
'Test file not found in asset bundle: $path ($bundleError)',
);
}
final file = File(path);
if (!await file.exists()) {
throw EnsembleTestFailure('Test file not found: $path');
}
return parseString(await file.readAsString(), sourcePath: path);
}