0

I wrote unittest-based tests with pytest. according to this document: https://docs.pytest.org/en/7.1.x/how-to/unittest.html then I tried to run the tests by Python testing in Visual Studio Code according to this document: https://code.visualstudio.com/docs/python/testing but when I select the Debug Test icon next to that test in the Test Explorer. VS Code starts the debugger but it doesn't pause at the breakpoints. how can I make it to stop at the breakpoints?

yofige
  • 3
  • 3

1 Answers1

0

According to what has been explained here, when we use "--cov" option for pytest, the VSCode doesn't stop at breakpoints. So the solution is to disable cov while debugging according to this in your VSCode launch.json add the followings:

   // your other settings are here
   {
    "name": "Debug Unit Test",
    "type": "python",
    "request": "launch",
    "justMyCode": true,
    "program": "${file}",
    "purpose": ["debug-test"],
    "console": "integratedTerminal",
    "env": {
        "PYTEST_ADDOPTS": "--no-cov"
    },
}
Hoda
  • 36
  • 6