Skip to content

Run tests with coverage #5463

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

Merged
merged 5 commits into from
May 10, 2021
Merged

Run tests with coverage #5463

merged 5 commits into from
May 10, 2021

Conversation

stevemessick
Copy link
Member

@stevemessick stevemessick commented May 5, 2021

This enables the "Run with Coverage" option on the main toolbar, and in the various Run menus. The toolbar button is the right-most one in this screen shot:
Screen Shot 2021-05-07 at 7 27 25 AM

All test modes are supported: all in directory, file, or filtered by name.

This feature re-uses the Java coverage framework. When tests first run you are asked if you want to delete the newly-created coverage data file. Say no! If you delete it you will not be able to see coverage data, even in future runs. (There must be someway to cause it to show, but I have not found it.)
Screen Shot 2021-05-07 at 7 28 07 AM

After running tests, the Cover tool window allows tests to easily be re-run with coverage by using its version of the "Run with Coverage" button.
Screen Shot 2021-05-07 at 7 28 36 AM

There is still work to be done. The Java coverage support includes two things we do not:

  • The coverage tool window that displays coverage data in a table
  • The ability to generate coverage reports to view in a browser

@google-cla google-cla bot added the cla: yes label May 5, 2021
}
else {
return info.coveredFilesCount == 0
? FlutterBundle.message("coverage.string.0.of.1.files.covered", info.coveredFilesCount, info.totalFilesCount)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the intended difference between these two messages. If 0 files are covered, it shows "0 of Y files covered", but if more are covered it shows "X of Y file"? Is it not clear that the 0 case is describing amount of coverage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I just copied what the Dart plugin did. You're right, it probably needs to be simplified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...it probably needs to be simplified.

Or, better yet, removed, since it is only used by the tool window we have not yet implemented. I removed two unused methods (and bundle strings). I also edited the description of this PR to identify outstanding work.

}

public void setCoverageRunner(@Nullable final CoverageRunner coverageRunner) {
final String path = myCoverageFilePath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does path get set to myCoverageFilePath and then the latter is set to the former? Maybe a comment here would be helpful. Also confusing to see that myCoverageFilePath is set again later in the constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment explaining that the super method clears the value and we want to keep it. It seems like the constructor could just call the super method directly. This code went through quite a few iterations while trying to figure out how to make the Java coverage framework for us. Thanks for catching things that need cleaning up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants