vscode-codeql icon indicating copy to clipboard operation
vscode-codeql copied to clipboard

Keyboard shortcut to run a test

Open gsingh93 opened this issue 4 years ago • 3 comments

I have a file called Test.ql, and I see this file show up in the "Testing" window. I can click on the run button in that window and have my test run. However, it would be convenient if there was a keyboard shortcut that would run the open query as a test if it was a test. I checked the commands under codeQLTests.* and didn't see anything I could bind to a key to do this.

https://github.com/github/vscode-codeql/issues/1026#tasklist-block-176af40d-810a-4093-b5d3-28c065086fce

gsingh93 avatar Dec 01 '21 00:12 gsingh93

@gsingh93 @aeisenberg I have looked upon this issue. For adding a keyboard shortcut you need to follow the following steps:

  1. Open the Keyboard Shortcuts Settings: Press Ctrl + K followed by Ctrl + S to open the Keyboard Shortcuts settings in Visual Studio Code(May vary on the ide you are using). Alternatively, you can go to the menu and select File -> Preferences -> Keyboard Shortcuts.

  2. Search for the Command: In the Keyboard Shortcuts settings, there is a search box. Enter a relevant keyword, such as "testing" or "run test"

  3. Assign a Keybinding: assign a key binding to the command testing.run, by clicking the + button.

  4. Define the Keybinding: Enter the desired key combination for the shortcut in the text input field. Ensure that the key combination you choose is not conflicting with any existing keybindings. For example, you can use "Ctrl+Shift+T" or "Cmd+Shift+T" (on Mac).

  5. Save the Keybinding: Press Enter to save the new keybinding.

  6. Verify and Apply Changes: Check that your new keybinding appears correctly in the list of keybindings. You can now close the Keyboard Shortcuts settings.

Hope this helps!

VardaQuraishi avatar Jun 21 '23 09:06 VardaQuraishi

Thanks, I'm still having some issues with this though.

After binding testing.run to a key, opening up the test's QL file and pressing the key does nothing. I also tried the existing key binding for testing.runCurrentFile and that didn't work, I see a tooltip that says "No tests found in this file".

But opening up the command palette and running "Test Explorer: Run tests in current file" works. Are you able to reproduce this behavior? I'm not sure why the command palette command would work but the keybinding for it wouldn't.

gsingh93 avatar Jun 21 '23 16:06 gsingh93

Have you also tried key binding to these commands as well? testing.runSelected, or testing.run .

VardaQuraishi avatar Jun 23 '23 06:06 VardaQuraishi