Skip to content
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

Keyboard shortcut for running unit tests #14805

Open
boaz-chen opened this issue May 14, 2023 · 6 comments
Open

Keyboard shortcut for running unit tests #14805

boaz-chen opened this issue May 14, 2023 · 6 comments
Labels
C-feature Category: feature request

Comments

@boaz-chen
Copy link

Currently, in order to run a unit test from within vscode, one must use the mouse, hover over the test function name they care about, and click Run Test. This is not very accessible, and also hurts the workflow of keyboard oriented developers.

image

I would like to suggest adding an action (that can have a keyboard shortcut attached to) called: Run selected test. This test will run the test the keyboard cursor is currently on.

Thanks for all the hard work!

@boaz-chen boaz-chen added the C-feature Category: feature request label May 14, 2023
@gavofyork
Copy link

This would be hugely useful. Furthermore, a similar keyboard shortcut to run all tests in the current file (i.e. click the "Run Test" label at the top of the file) would be similarly useful.

@matklad
Copy link
Member

matklad commented Nov 28, 2023

If I am not missing anything, the VS Code action called

“Rust Analyzer: Run”

is doing exactly this, and has been there since forever. The action is documented here:

https://rust-analyzer.github.io/manual.html#run

To bind it to a shortcut, use this config:

https://github.com/matklad/config/blob/caedcf2cb24dac5154b9e081240b0019382d3ec9/home/.config/Code/User/keybindings.json#L6

@adstep
Copy link

adstep commented Dec 1, 2023

The command 'rust-analyzer.run' adds a little complexity to the process of running the selected test. It first prompts the user to select a runnable that they want to execute, this can include tests and a number of other possible actions.

The ask was explicitly for a command that would immediately run the selected test. While the existing run command allows the user to accomplish running the test without using the mouse, this new run selected test command would minimize the actions a user has to take.

See run command.

If I am not missing anything, the VS Code action called

“Rust Analyzer: Run”

is doing exactly this, and has been there since forever. The action is documented here:

https://rust-analyzer.github.io/manual.html#run

To bind it to a shortcut, use this config:

https://github.com/matklad/config/blob/caedcf2cb24dac5154b9e081240b0019382d3ec9/home/.config/Code/User/keybindings.json#L6

@koptan
Copy link

koptan commented Dec 15, 2023

+1

@ktodyruik
Copy link

+1. This would be extremely useful. 'rust-analyzer.run' is not sufficient. The goal would be to bind a key to the 'Run Test' or 'Run Tests' button.

@matklad
Copy link
Member

matklad commented Jun 9, 2024

I think this can be handled on the type-script side. Basically, we should add an optional argument to rust-analyzer.run command. Something like ?mode: "rerun" | "selection", where "rerun" make it rerun last task, and "selection" makes it run the selected thing.

Useful links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

6 participants