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

Adding docs for test coverage #7615

Merged
merged 10 commits into from
Oct 3, 2024
Merged

Adding docs for test coverage #7615

merged 10 commits into from
Oct 3, 2024

Conversation

cwebster-99
Copy link
Member

@cwebster-99 cwebster-99 commented Sep 20, 2024

Updating our test docs to include a section for test coverage. We want to focus on the setup needed for running python tests with coverage and link to generic VS Code docs on coverage for everything else.

@eleanorjboyd
Copy link
Member

looks awesome- thanks for the cleanup / rewording to make it flow and sound much better!

docs/python/testing.md Outdated Show resolved Hide resolved
To run tests with coverage, select the coverage run icon in the Test Explorer or “Run with coverage” from any menu you normally trigger test runs from. The Python extension will run coverage using the [`pytest-cov`](https://pypi.org/project/pytest-cov/) plugin if you are using pytest, or with [`coverage.py`](http://coverage.py/) for unittest.
> **Note**: Before running tests with coverage, make sure to install the correct testing package for your project.

Once the coverage run is complete, lines will be highlighted in the editor for line level coverage. These can be closed and re-opened via the Run Results panel in the bottom where it says "Close Test Coverage" or "View Test Coverage" under the most recent test run. Additionally, a Test Coverage tab will appear below the Testing tab in the Test Explorer, also with a beaker icon, which you can also navigate to with **Testing: Focus on Test Coverage View** in Command Palette (`kbstyle(F1)`). On this panel you can view line and branch coverage metrics for each file and folder in your workspace.
Copy link
Member

Choose a reason for hiding this comment

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

need to remove references to branch coverage metrics as these are no longer a part of this release


![]()

For finer grain control of your coverage run when using pytest, you can edit the `python.testing.pytestArgs` to include your specifications. When the pytest argument `—cov` exists in `python.testing.pytestArgs`, the Python extension will make no edits to coverage args to allow the user’s customizations to take effect. If there is no `-cov` argument found, the extension will add `-cov=.` and `-cov-branch` to the pytest args prior to run to enable branch level coverage at the workspace root.
Copy link
Member

Choose a reason for hiding this comment

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

remove " and -cov-branch", also change prior to run to enable branch level coverage at the workspace root. to prior to run to enable coverage at the workspace root.

docs/python/testing.md Outdated Show resolved Hide resolved
docs/python/testing.md Outdated Show resolved Hide resolved
docs/python/testing.md Outdated Show resolved Hide resolved
@cwebster-99 cwebster-99 marked this pull request as ready for review September 30, 2024 19:22
@vs-code-engineering vs-code-engineering bot added this to the October 2024 milestone Sep 30, 2024
docs/python/testing.md Outdated Show resolved Hide resolved
docs/python/testing.md Outdated Show resolved Hide resolved
docs/python/testing.md Outdated Show resolved Hide resolved
Test coverage is a measure of how much of your code is covered by your tests, which can help you identify areas of your code that are not being fully tested. For more information on test coverage, visit VS Code's [Test Coverage documentation](/docs/editor/testing#test-coverage.md).

To run tests with coverage, select the coverage run icon in the Test Explorer or “Run with coverage” from any menu you normally trigger test runs from. The Python extension will run coverage using the [`pytest-cov`](https://pypi.org/project/pytest-cov/) plugin if you are using pytest, or with [`coverage.py`](http://coverage.py/) for unittest.
> **Note**: Before running tests with coverage, make sure to install the correct testing package for your project.
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this note could be misleading since you don't need to install unittest, as it's built-in? Or maybe this could be tweaked to say "install the correct testing coverage package for your project"?

docs/python/testing.md Outdated Show resolved Hide resolved
To run tests with coverage, select the coverage run icon in the Test Explorer or “Run with coverage” from any menu you normally trigger test runs from. The Python extension will run coverage using the [`pytest-cov`](https://pypi.org/project/pytest-cov/) plugin if you are using pytest, or with [`coverage.py`](http://coverage.py/) for unittest.
> **Note**: Before running tests with coverage, make sure to install the correct testing package for your project.

Once the coverage run is complete, lines will be highlighted in the editor for line level coverage. These can be closed and re-opened via the Run Results panel in the bottom where it says "Close Test Coverage" or "View Test Coverage" under the most recent test run. Additionally, a Test Coverage tab will appear below the Testing tab in the Test Explorer, also with a beaker icon, which you can also navigate to with **Testing: Focus on Test Coverage View** in Command Palette (`F1)`). On this panel you can view line coverage metrics for each file and folder in your workspace.
Copy link
Member

Choose a reason for hiding this comment

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

This is a nit suggestion so feel free to disregard it, but I think we could simplify this paragraph by suggesting one way to view coverage (e.g. through the test explorer), as the other ones are covered in the VS Core core doc.

luabud
luabud previously approved these changes Oct 1, 2024
@ntrogh
Copy link
Contributor

ntrogh commented Oct 1, 2024

@cwebster-99 should this go out with the upcoming release?

Co-authored-by: Luciana Abud <45497113+luabud@users.noreply.github.com>
docs/python/testing.md Outdated Show resolved Hide resolved
docs/python/testing.md Outdated Show resolved Hide resolved
@cwebster-99
Copy link
Member Author

cwebster-99 commented Oct 1, 2024

@cwebster-99 should this go out with the upcoming release?

@ntrogh That would be great!

docs/python/testing.md Outdated Show resolved Hide resolved
@ntrogh ntrogh merged commit 3db52e4 into main Oct 3, 2024
2 checks passed
@ntrogh ntrogh deleted the py-coverage branch October 3, 2024 09:44
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.

4 participants