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
Please sign in to leave a comment.
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
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.
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
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.
I'm afraid you cannot add this action in toolbar at the moment.
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.
Such stuff can be implemented by existing macros and UI settings config sub-systems. The basic idea is to do the following:
I've created a small screencast which illustrates the whole process - https://dl.dropbox.com/u/1648086/video/run.m4v
Denis
Nice, I will use that too :) Thanks.
Cool, thanks Denis. I will give this a try.
- Z
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"
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.
Hello Phedwards,
You may use the run button in the gutter to run the particular test class or method.
@...
It's quite a while ago that you brought that up, so just in case someone else passes by:
I had the same problem but I found this solution:
Ref: https://stackoverflow.com/a/6397315/3097432
By doing that, the green play buttons showed up next to my
def test_….