The question is regarding Visual Studio Code (VSCode from here) and python VSCode extension that finds and runs py.test tests.
Is it possible to assign some shortcut to run current (under cursor) test method and/or test class?
I really like the ability to run single test straight from VSCode, but my workflow is not optimal since it is necessary to click it and just use some shortcut.
This image shows the buttons that appear when tests are found and can be run. I would like to know if it is possible to just use some custom shortcut instead of clicking this buttons.
Open a Python project. Once the project is loaded in Visual Studio, right-click your project in Solution Explorer and select the unittest or pytest framework from the Properties Test tab. If you use the pytest framework, you can specify test location and filename patterns using the standard pytest .
Once you have the Python extension installed and a Python file open within the editor, a test beaker icon will be displayed on the VS Code Activity bar. The beaker icon is for the Test Explorer view. When opening the Test Explorer, you will see a Configure Tests button if you don't have a test framework enabled.
Try Test Explorer UI and Python Test Explorer for Visual Studio Code.
The command list:
However, run-test-at-cursor
doesn't work for me. I use run-file
. Moreover, maybe you should join workbench.action.files.save
, test-explorer.reload
, and test-explorer.run-test-at-cursor
with a macro extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With