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

Answered

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

12 comments
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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

0
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

Nice, I will use that too :)  Thanks.

0
Comment actions Permalink

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

- Z

0
Comment actions Permalink

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"

1
Comment actions Permalink

Agree it would be better for the green Run triangle button to run the current open program on display rather than re-running the last program.

0
Comment actions Permalink

Hello Phedwards,

You may use the run button in the gutter to run the particular test class or method.

0

Please sign in to leave a comment.