问题
I have several launch configurations for the code I work on.
One configuration (#1) means "run the unit tests for the file in the frontmost editor (i.e. selected resource)". I would really like to be able to always make this be bound to a key.
Another configuration (#2) means "run the server that I am working on (in the frontmost project) so I can test it interactively".
Yet another (#3) means "run some automated acceptance tests against the server".
I always want to have #1 close at hand, easy to run from a single keystroke. Plus, I want to be able to run #2, watch it start up in a console, and when it's ready (since it's not entirely trivial to automate this) hit the key for #3.
This is possibly similar to the question for binding a key to a specific build configuration, but the answers there look very specific to builds, and as I'm using PyDev, I don't have a "build" step at all.
Also, given that I'm using PyDev, an answer in the form of a pyedit_*
script would be appreciated just as much as a "native" answer for eclipse.
回答1:
Maybe Eclipse Runner plugin could make it easier for someone to handle launch configurations. It doesn't allow to assign key binding to launch configurations currently but I opened a feature request Key bindings for launch configurations
回答2:
Not to a specific launch Configuration , but you can bind a key to run Last run Configuration ,
Windows->preferences->General->Keys->Run last launched external Tool
回答3:
You can do the following (for #2 and #3), after having those run configurations created:
Go to Run > Run Configuration > Select the run configuration you want > Common > Display in Favorites Menu > Check Run/Debug
. This will make it always appear as the first on the menu.
This will make it appear in the menu in Run > History
and Run > Debug History
, then, you can access it through Alt+R, T, 1
(and 2
and 3
) to run your configurations or Alt+R, H, 1
(and 2
and 3
) to debug.
And for #1, as Piotr Dobrogost
said, you can just use Ctrl+F9
in the current editor and choose which test-cases you want to run (if you select a unit-test -- usually with Ctrl+Shift+Up
or Ctrl+Shift+Down
-- it'll be pre-selected for you) -- then, if you configured to always relaunch the last launch, as explained in http://www.pydev.org/manual_101_run.html, you can use Ctrl+F11
to relaunch the last launch.
来源:https://stackoverflow.com/questions/3125257/how-can-i-bind-a-specific-key-to-different-launch-configurations-in-eclipse