IntelliJ keyboard shortcut for a particular run configuration

Intellij Idea

Intellij Idea Problem Overview


I have a JUnit run configuration to run all my unit tests.

How can I bind a keyboard shortcut to the run of that JUnit config?

Intellij Idea Solutions


Solution 1 - Intellij Idea

There is now a third-party plug-in:

Workarounds without plug-ins:

  1. Use Run | Run... (Alt+Shift+F10) on Windows to quickly select the configuration to Run or Debug

  2. Run the tests from the Ant script target, IDEA allows to assign keyboard shortcuts for the selected targets in Settings | Keymap.

Solution 2 - Intellij Idea

You can also create a Macro and assign a shortcut to that Macro as a workaround.

  1. Go to Edit | Macros | Start recording macro
  2. Press Alt+Shift+F10 to show Run dialog
  3. Start typing the name of the desired Run Configuration (Just type enough to distinguish it from other run configurations)
  4. Press Enter to run the Run Configuration
  5. Go to Edit | Macros | Stop recording macro and choose a proper name for recorded macro.
  6. Now you can assign a keyboard shortcut to your macro from the Preferences | Keymap (Type the name of recorded macro in the search box).

Solution 3 - Intellij Idea

I've created plugin for this Run Configuration as Action. After loading of this plugin it register all Run/Debug configurations as actions. So you can assign shortcut for them, add them to toolbars, etc. enter image description here

It works for all Jetbrains IDEs based on IntelliJ platform: CLion, PyCharm, PhpStorm, etc.

Solution 4 - Intellij Idea

  1. Install the Infinitest plug into IntelliJ.

(After installing the plugin from the Plugin Manager, enable the Infinitest facet for your project. Right click on the project, choose facet, add Infinitest.)

  1. To run all tests, Make the project with ⌘-F9 (Mac). This runs all your tests regardless of what the current Run configuration is. You get a nice green message in your face if they pass, a red message also in your face if there's a fail.

It's a bit workaround-y but it works for me. I like that I don't have to engage with any dialogues.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJavaRockyView Question on Stackoverflow
Solution 1 - Intellij IdeaCrazyCoderView Answer on Stackoverflow
Solution 2 - Intellij IdeaNader GhanbariView Answer on Stackoverflow
Solution 3 - Intellij IdeaturbanoffView Answer on Stackoverflow
Solution 4 - Intellij IdeaReturn_Of_The_ArchonsView Answer on Stackoverflow