-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Conversation
looks awesome- thanks for the cleanup / rewording to make it flow and sound much better! |
docs/python/testing.md
Outdated
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. |
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.
need to remove references to branch coverage metrics
as these are no longer a part of this release
docs/python/testing.md
Outdated
|
||
![]() | ||
|
||
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. |
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.
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
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. |
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 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
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. |
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.
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.
@cwebster-99 should this go out with the upcoming release? |
Co-authored-by: Luciana Abud <45497113+luabud@users.noreply.github.com>
@ntrogh That would be great! |
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.