testReader static method
Reads the tests from the clipboard. There can be one or more tests in the
clipboard. This ignores the context
that is passed in. This will
never throw an error or return null
and will instead return an empty
array if it encounters issues loading the tests.
If the suiteName
is not-null, this will exclude any tests that are not
same test suite.
Implementation
static Future<List<PendingTest>> testReader(
BuildContext context, {
String? suiteName,
}) async {
var tests = <PendingTest>[];
try {
var data = await Clipboard.getData('text/plain');
var text = data?.text;
if (text?.isNotEmpty == true) {
var parsed = json.decode(text!);
tests = TestStore.createMemoryTests(parsed);
}
tests.removeWhere(
(test) => suiteName?.isNotEmpty == true && suiteName != test.suiteName,
);
} catch (e, stack) {
_logger.severe('Error in ClipboardTestStore.testReader', e, stack);
}
return tests;
}