how to ignore a line in `dart-lang/coverage`

1,339

Solution 1

at the moment is not possible

to exclude a line for code coverage in dart and flutter (see this issue)

I'm disambiguating the question about what is the correct way to test super keyword

Solution 2

I see this. Not perfect, but a solution

// coverage:ignore-line to ignore one line.
// coverage:ignore-start and // coverage:ignore-end to ignore range of lines inclusive.
// coverage:ignore-file to ignore the whole file.

Solution 3

In documentation for widget_tester.dart

testWidgets('MyWidget asserts invalid bounds', (WidgetTester tester) async {
  await tester.pumpWidget(MyWidget(-1));
  expect(tester.takeException(), isAssertionError); // or isNull, as appropriate.
});
Share:
1,339
Francesco Iapicca
Author by

Francesco Iapicca

Self taught developer in love with Flutter and Dart

Updated on December 27, 2022

Comments

  • Francesco Iapicca
    Francesco Iapicca over 1 year

    use case

    codecov sees super as in need for test,

    enter image description here

    not sure being sure if writing a test for this keyword

    • would be meaningful
    • how to write such a test

    I'd like to exclude the line from coverage until my doubts are cleared

    question

    how do I ignore a line in dart-lang/coverage

  • Francesco Iapicca
    Francesco Iapicca over 3 years
    thanks, but what about super? [editing the question] also... it's not a widget
  • Christian Findlay
    Christian Findlay over 2 years
    A lot people are saying it was fixed, but I'm on the latest version of Flutter and it still doesn't appear to be fixed. I can ignore a whole file, but I cannot ignore sections of a file.