Missing toolbar one-click button to run opened file unit test?

Hi there,

The IntelliJ toobar has the "Run" (green triangle) button, but it only runs the last-ran test, or select to change to previous ran test. However, often times, I want to run a newly opened unit test file in IDE. I can not do this with a single click button, but only by pressing "CTRL+SHIFT+10" on the new test file. That's a lot of keystroke for a frequent operation. Is there way I can configure a one-click button to run the unit file file I just opened?

Thanks,
Zemian

10 comments

Hi Zemian,

You can right-click at the editor and choose 'Run' context menu item. It does exactly the same as Ctrl+Shift+F10.

Denis

0

You can use Shift-F10 (action "Run"). This is context-based action, so when you in editor inside test class, it will run the method where the caret is. If you are in Project tree it runs current selection (all tests in class or all tests in package).
And of course, you can assign another shortcut for this action if you need.

0

Yes, Denis, but that's still a two step process, and I have to eye it very carefully since there are many choices with context Menu.

As a developer, my use case of open a unit test in IDE and run it immediately is very frequent. I want this to be as quick as possible. I want open the file, then one click to run it. Is there any way I can do this?

Not sure if it's just me, or anyone else has the same feeling. I would much prefer the toolbar default the "Run" button to run current open unit test file instead of last ran test.

- Zemian

0

Thanks Vassiliy,

Ah, yes, thanks for bring up SHIFT+F10 shortcut. Yes, that's what I want, but I want a button instead of pressing the key stroke. I much prefer that green triangle button on the current toolar to perform SHIFT+F10 on opened file instead of running the last ran test, which I find it less useful.

0

I'm afraid you cannot add this action in toolbar at the moment.

0

Wait a moment, that green triangle performs SHIFT+F10, what you really need is CTRL+SHIFT+F10 - Run context configuration, as you previously wrote, and you could maybe write a plugin for that.

0

Such stuff can be implemented by existing macros and UI settings config sub-systems. The basic idea is to do the following:

  1. Create a macros which emulates Ctrl+Shift+F10. It's done via two actions - Escape (moves focus to the editor) and 'Run context configuration' action;
  2. Configure the toolbar in order to provide a new button which is mapped to the macros above. Custom icon might be set for that button;

I've created a small screencast which illustrates the whole process - https://dl.dropbox.com/u/1648086/video/run.m4v

Denis

0

Nice, I will use that too :)  Thanks.

0

Cool, thanks Denis. I will give this a try.

- Z

0

It is ridiculous a standard run toolbar icon is not on the main toolbar by default.

File -> Settings -> Appearance and Behavior -> Menus and Toolbars
Add the Actions under Other
"Run context configuration" and "Debug Context Configuration"

0

Please sign in to leave a comment.