expectListCountFinder method
void
expectListCountFinder(})
Implementation
void expectListCountFinder(
Finder listFinder, {
required int expected,
Finder? itemFinder,
bool atLeast = false,
String description = 'target list',
}) {
return RunnerBenchmark.sync('assertion', 'expectListCountFinder', () {
if (listFinder.evaluate().isEmpty) {
throw EnsembleTestFailure('expectListCount: $description not found.');
}
final count = itemFinder != null
? find
.descendant(of: listFinder, matching: itemFinder)
.evaluate()
.length
: find
.descendant(
of: listFinder, matching: find.byWidgetPredicate((_) => true))
.evaluate()
.length;
if (atLeast) {
if (count < expected) {
throw EnsembleTestFailure(
'Expected at least $expected items in $description, found $count.',
);
}
return;
}
if (count != expected) {
throw EnsembleTestFailure(
'Expected $expected items in $description, found $count.',
);
}
});
}