Skip to content

IntelliJ code coverage tools don't show coverage per-line using source maps #40031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
whesse opened this issue Jan 9, 2020 · 3 comments
Closed
Labels
area-intellij Tracking issues for the Dart IntelliJ plugin. area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.

Comments

@whesse
Copy link
Contributor

whesse commented Jan 9, 2020

I am trying to measure and improve test coverage in an Angular Dart project (the Dart CI results feed at https://dart.googlesource.com/dart_ci/+/refs/heads/master/results_feed/)

The Intellij coverage tools work adequately to run tests written using

  import 'package:angular_test/angular_test.dart';
  import 'package:pageloader/html.dart';
  import 'package:test/test.dart';

and produce coverage reports for the Dart source files that seem correct.
The source file coverage does not show line-by-line coverage, though, which is
needed to find out where which functions aren't being covered, and add tests.

The data file stored by intellij for this dart2js coverage data is in [home]/.IntelliJIdea2019.3/system/coverage, and is a .dat file with data like:
SF:/src/dart/dart_ci/results_feed/lib/src/services/filter_service.dart DA:8,1 DA:9,1 DA:10,1 DA:12,1 DA:13,1 DA:14,0 DA:15,1 DA:17,1 DA:21,0 DA:22,0 DA:23,0 DA:24,0 DA:25,0 DA:26,0 DA:27,0
I can look at that by hand, and see what lines are covered, but the IntelliJ UI components to show it are missing when looking at this type of coverage report, which is called "WipPresentableName Coverage" in the Choose Coverage Suite IntelliJ IDEA dialog. There is no color highlighing of the lines, or option to export the data.

The tests that I run on the Dart VM, because they are unit tests with no UI, have a different type of coverage data called "Dart Coverage", which is stored as a .json file in the coverage directory
and has similar data, like
{"source":"package:intl/src/intl/date_format.dart","script":{"type":"@Script","fixedId":true,"id":"libraries/1/scripts/package%3Aintl%2Fsrc%2Fintl%2Fdate_format.dart","uri":"package:intl/src/intl/date_format.dart","_kind":"library"},"hits":[579,3,643,3,690,0,702,0,710,3,240,1,246,2,247,1,411,0,412,0,413,0,414,0,415,0,416,0,417,0,418,0,419,0,420,0,421,0,422,0,423,0,424,0,425,0,426,0,427,0,428,0,429,0,430,0,431,0,432,0,433,0,434,0,435,0,436,0,437,0,438,0,439,0,440,0,441,0,442,0,443,0,444,0,445,0,446,0,447,0 ...
do show line-by-line coverage highlighting in the IntelliJ IDEA ui.

If I run the app or tests directly in the Chrome browser, and use its devtools coverage tools, I do get line-by-line coverage highlighting in the Dart source files, though I'm not confident of its accuracy, as long as the source files can be fetched by the browser. I have a hard time running the web tests directly in the browser, though - if I load the test HTML page, it seems not to run the tests.

What is our expected workflow for looking at test code coverage in Angular apps? An issue filed against the Angular Dart repository a year ago was closed as not their job:
angulardart/angular#1654

Can we get the IDEA ui to show the line-by-line coverage? And how accurate are the source maps and their use for coverage data from browser execution? Some of the results I've seen don't really look right.

@whesse whesse added area-intellij Tracking issues for the Dart IntelliJ plugin. area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels Jan 9, 2020
@whesse
Copy link
Contributor Author

whesse commented Jan 9, 2020

@grouma @jacob314 Does the Dart - Flutter axis have any work that would help in coverage of web Dart code?

@grouma
Copy link
Member

grouma commented Jan 9, 2020

Externally we don't have support for web coverage. There is a very long discussion which captures some approaches in dart-lang/test#36. It hasn't been a large enough priority for us to tackle unfortunately.

@joshualitt
Copy link
Contributor

Closing because AngularDart is in maintenance mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-intellij Tracking issues for the Dart IntelliJ plugin. area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.
Projects
None yet
Development

No branches or pull requests

3 participants