test-coverage icon indicating copy to clipboard operation
test-coverage copied to clipboard

Exclude files

Open long1eu opened this issue 6 years ago • 8 comments

Hi!

I'm using this pub run test_coverage --exclude="**.g.dart" to exclude generated file. Seem that it doesn't work.

Any idea?

long1eu avatar Jul 11 '19 13:07 long1eu

exclude option is only for excluding some files inside test folder, e.g. if you have any fixtures there.

Looks like you are trying to exclude some source files, which is not possible at this point.

pulyaevskiy avatar Jul 12 '19 05:07 pulyaevskiy

There's a library that currently handles this: jack-r-warren/remove_from_coverage. Any chance of merging that functionality here?

chimon2000 avatar Apr 21 '20 01:04 chimon2000

How could i ignore .g.dart files while running pub run test_coverage ?

awaiting for solution

ishaileshmishra avatar Apr 22 '20 07:04 ishaileshmishra

The underlying coverage package should ignore source code when you use special comments described here (see the end of the page). I am trying to use them, but for some reason they don't work. Is it an issue with coverage or is it test_coverage?

rasuru avatar Jul 24 '20 16:07 rasuru

Okay, I found some PRs about this:

  1. https://github.com/flutter/flutter/pull/61408
  2. https://github.com/dart-lang/coverage/pull/246

It seems it's either implemented, but does not work for me for some reason, or still being worked on. I don't quite get it, can anyone help?

rasuru avatar Jul 24 '20 16:07 rasuru

If I got it right, they implemented the feature, but this package is not up to date with the changes. Does anyone plan to update test_coverage?

rasuru avatar Jul 24 '20 17:07 rasuru

I can update dependencies to the latest. Though whichever package generated your *.g.dart files also needs to be updated to include those new comment blocks, right? Is this addressed already as well?

pulyaevskiy avatar Jul 28 '20 00:07 pulyaevskiy

Oh well, there are workarounds to excluding generated files, or maybe even convenient ways to do it. I just want to use these comments in some of my files, where I declared Moor tables. Then *.g.dart files are generated from these declarations, but they are not referenced anywhere else in code, which leads to them not being included in coverage. I would like to see realistic coverage that I have control over. Would appreciate if you update dependencies :smile_cat:

rasuru avatar Jul 29 '20 12:07 rasuru