question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot debug single unit test anymore

See original GitHub issue

Environment data

  • VS Code version: 1.25.1
  • Extension version (available under the Extensions sidebar): 2018.7.1
  • OS and version: Windows 7 (also tried on Windows 10)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
  • Relevant/affected Python packages and their versions: Unit Testing

Actual behavior

Clicking on the ‘Debug Test’ link of a unit test method (not class!) results in all the unit tests of that class to execute. Quick analysis: The problem stems from the code change in #2066 on line 300, where a ‘break’ has been added in the first condition. Removing this makes the code work as before.

It also seems that the second condition (line 301) will never be reached due to this ‘break’. This is because the first condition (line 298) is a more lenient check and will always be true when the second more stricter check is true. Unfortunately due to the ‘break’ the first condition will assign the whole class as the desired tests instead of the single test, which is assigned if he second condition is true.

Expected behavior

Only the selected unit test method should execute, as was the case earlier.

Steps to reproduce:

  1. Create a unit test class (derived from unittest.TestCase)
  2. Create a couple of unit test methods.
  3. Assuming that the unit tests are discovered and the ‘Run Test| Debug Test’ links are visible, click on the Debug Test link of a method. --> All the Unit tests execute instead of only the desired test.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

N/A, please see issue above

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

N/A, please see issue above

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
F4h4D-T-Qcommented, Jul 27, 2018

@brettcannon : “python.jediEnabled”: true. Sorry for not understanding your question, I only recently started using Visual Studio Code (and think it’s great!) so still a lot to learn and discover.

0reactions
d3r3kkcommented, Aug 8, 2018

Should be fixed in the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio - suddenly cannot debug tests - Stack Overflow
Only one unit test could not be debugged in my case. Debugger would initialize a test, but would not debug test itself, nicely...
Read more >
Can't run or debug unit tests - Visual Studio Feedback
I'm using Visual Studio Community Edition 15.8.1 and I can't run or debug any unit tests. Every time I'm trying to run the...
Read more >
Debug unit tests with Test Explorer - Visual Studio (Windows)
In Test Explorer, select the test method(s) and then choose Debug on the right-click menu. Test execution details. For more information, about ...
Read more >
Debug Angular 12 Karma Tests in VSCode - Medium
However, you typically don't want to run your full test suite when you're debugging tests in just one file. I like the convenience...
Read more >
Unable to test a test method in debug mode : r/csharp - Reddit
For a sanity check, try doing a "clean" and for good measure, go manually delete the bin and obj folders related to every...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found