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

TPI: Coverage with unittest #24160

Closed
3 tasks done
eleanorjboyd opened this issue Sep 23, 2024 · 1 comment
Closed
3 tasks done

TPI: Coverage with unittest #24160

eleanorjboyd opened this issue Sep 23, 2024 · 1 comment

Comments

@eleanorjboyd
Copy link
Member

eleanorjboyd commented Sep 23, 2024

Refs: #22827

Complexity: 5

Author: @eleanorjboyd

Create Issue

Create Issue


In this TPI you will be testing the new coverage implementation for Python with UNITTEST.

Find or create a python project that has tests and test coverage. Hopefully copilot can help you with this but you can also look at my testing example repo and specifically this test which will call my inc_dec.py file with functions: https://github.com/eleanorjboyd/inc_dec_example_repo/blob/main/inc_dec_example_test_suite/test_two_classes.py.

  1. Create a venv using the "create environment command" choose python >= 3.8
  2. In the terminal, run python -m pip install coverage.
  3. From the command palette, run "python: configure tests", select unittest and then "." (root directory or whatever folder your tests are located in)
  4. EDIT: now reload vscode window (this should mitigate an outstanding bug)
  5. click the test explorer icon (beaker)
  6. run tests with coverage using the button
  7. look at coverage by clicking the beaker icon below the test explorer icon
  8. create a function that has an "if / else" block, create tests so only one of those conditionals is met, make sure the UI shows the conditional you missed as not covered which will also appear red in the editor for that function.
  9. try different things and make sure they react correctly, ideas like: comments (shouldn't count towards coverage), blank lines (shouldn't count), blank files (shouldn't count and coverage should be grey in the coverage tab)
@mjbvz
Copy link

mjbvz commented Sep 25, 2024

Marking as tested but wasn't able to complete the inline test coverage part on windows. Can revisit this once #24178 is fixed

@mjbvz mjbvz closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants