Skip to content

Keyboard shortcut to run a test #1026

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

Open
gsingh93 opened this issue Dec 1, 2021 · 3 comments
Open

Keyboard shortcut to run a test #1026

gsingh93 opened this issue Dec 1, 2021 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers VSCode

Comments

@gsingh93
Copy link
Contributor

gsingh93 commented Dec 1, 2021

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.

#1026 (comment)

@gsingh93 gsingh93 added the enhancement New feature or request label Dec 1, 2021
@github-actions github-actions bot added the VSCode label Dec 1, 2021
@aeisenberg aeisenberg added the good first issue Good for newcomers label Dec 1, 2021
@VardaQuraishi
Copy link

@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!

@gsingh93
Copy link
Contributor Author

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.

@VardaQuraishi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers VSCode
Projects
None yet
Development

No branches or pull requests

3 participants