-
Notifications
You must be signed in to change notification settings - Fork 332
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
Run tests with coverage #5463
Conversation
} | ||
else { | ||
return info.coveredFilesCount == 0 | ||
? FlutterBundle.message("coverage.string.0.of.1.files.covered", info.coveredFilesCount, info.totalFilesCount) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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:

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.)

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.

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