'Flutter: Coverage:ignore not working with async methods
I can't ignore any async Functions from code coverage. I try to exclude File.exists() from my Code coverage.
Attempts:
- Tried with // coverage:ignore-line -> not working
- Tried with coverage:ignore-start/end -> not working either
My Class File (minimal example):
class Coverage{
bool check(){ // coverage:ignore-line
return true; // coverage:ignore-line
}
Future<bool> asyncCheck() async { // coverage:ignore-line
return true; // coverage:ignore-line
}
bool someIrrelevantFunction(){
return true;
}
}
My Test File
void main() {
group('Code Coverage Test', () {
test('just a test', () {
Coverage cov = Coverage();
expect(cov.someIrrelevantFunction(), true);
});
});
}
My coverage:
SF:lib\gg.dart
DA:12,0 <-Async Function line, not ignored...
DA:16,1 <-someIrrelevantFunction line
LF:2
LH:1
end_of_record
Flutter 2.8, Android Studio
Solution 1:[1]
Seems to be working now with Flutter 3.0.0 and Dart version 2.17.0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ratloser |