Skip to content
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

Stub TestCoverage API #13631

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

rschnekenbu
Copy link
Contributor

What it does

Stub the new API introduced with vscode 1.88 about TestCoverage. This was previously a proposed API.

Fixes #13549

Contributed on behalf of STMicroelectronics

How to test

I did not have a testing plugin yet, as usual plugins used for testing are not implementing the coverage API. For example, Playwright does not yet implement code coverage as seen here: microsoft/playwright#30298.

Follow-ups

Implement TestCoverage API. This will be tracked as a task of #12010.

Review checklist

Reminder for reviewers

@tsmaeder
Copy link
Contributor

@rschnekenbu we should at least have a test plugin that exercises the stubbed code: extensions should at least not crash when they call the API.

Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

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

The FileCoverage API is weird in that you can assign to the public fields, but changes to those fields are not handled. Seems to be that same in VS Code, though. Seems undercooked for a GA API on their side, IMO.

constructor(public name: string, public executed: number | boolean, public location: Position | Range) { }
}
@es5ClassCompat
export class TestCoverageCount implements theia.TestCoverageCount {
Copy link
Contributor

Choose a reason for hiding this comment

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

theia.TestCoverageCount is not an interface. Why the "implements"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this declaration, that indeed makes no sense.

}

export namespace StatementCoverage {
export function is(coverage: unknown): coverage is StatementCoverage {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't instanceof work just as well, since this is a class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I removed this namespace addition in favor of a instanceof.

@rschnekenbu
Copy link
Contributor Author

I addressed the review comments in a following patch.
Here is a testing extension that adds coverage support for the test runs and also provides the optional method TestRunProfile.loadCoverageDetail for our TestRunProfile.
src: test-extension-sample-0.1.0-src.zip
extension:
test-extension-sample-0.1.0.zip

To run the extension:

  1. Start theia browser example on a workspace and install the provided extension
  2. Use the command to create a test run profile
  3. Then in the test run view, run the tests. They should run as usual, even if a coverage is added. No errors should be logged or displayed.

Here is the behavior on vscode 1.88:
vscode-13549

And on theia browser example:
theia-13549

contributed on behalf of STMicroelectronics

Signed-off-by: Remi Schnekenburger <[email protected]>
@rschnekenbu rschnekenbu merged commit 845b291 into eclipse-theia:master Apr 24, 2024
12 of 14 checks passed
@rschnekenbu rschnekenbu deleted the issues/13549-stub branch April 24, 2024 14:30
@jfaltermeier jfaltermeier added this to the 1.49.0 milestone Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[vscode] Stub TestCoverage API
3 participants