Description
Sometimes coverage is gathered from external packages even when --scope-output
flag is used and set to the name of the app's package.
Reproduction
- Create a new dart project with
dart create minimal-sample
- Add equatable package:
dart pub add equatable
- Replace the code inside
lib/minimal_sample.dart
with the code below:
import 'package:equatable/equatable.dart';
class SomeClass with EquatableMixin {
@override
List<Object?> get props => [];
}
int calculate() {
return 6 * 7;
}
- run
dart run --pause-isolates-on-exit --disable-service-auth-codes --enable-vm-service=8181 test &
dart pub global run coverage:collect_coverage --wait-paused --uri=http://127.0.0.1:8181/ -o coverage/coverage.json --resume-isolates --scope-output=minimal_sample
After performing the steps above, the generated coverage/coverage.json
looks like this:
{
"type": "CodeCoverage",
"coverage": [
{
"source": "package:minimal_sample/minimal_sample.dart",
"script": {
"type": "@Script",
"fixedId": true,
"id": "libraries/1/scripts/package%3Aminimal_sample%2Fminimal_sample.dart",
"uri": "package:minimal_sample/minimal_sample.dart",
"_kind": "library"
},
"hits": [
4,
0,
5,
0,
8,
1,
9,
1
]
},
{
"source": "package:equatable/src/equatable_mixin.dart",
"script": {
"type": "@Script",
"fixedId": true,
"id": "libraries/1/scripts/package%3Aequatable%2Fsrc%2Fequatable_mixin.dart",
"uri": "package:equatable/src/equatable_mixin.dart",
"_kind": "library"
},
"hits": [
16,
0,
18,
0,
21,
0,
22,
0,
23,
0,
26,
0,
27,
0,
29,
0,
31,
0,
32,
0,
33,
0,
34,
0,
35,
0,
37,
0,
38,
0,
39,
0
]
}
]
}
I use Dart SDK 3.3.3.