Plugin to set default Run/Debug settings

I'm relatively new to IntelliJ, and one time consumer for me has been the setting of run/debug defaults, particularly the environment and vm options sections.

At our shop we have basically 3 types of tests.  Unit tests with no outside dependencies. These tests have a single environment option and no special vm options in order to pass successfully.  When we run from gradle, these are set automatically, within Idea we need to set them manually.

Our integration tests have outside dependencies that require 4 environment elements and a fairly complex vm options.  In order to make sure unit tests stay pure, I do NOT want these options set when running unit tests.

Our end to end tests have yet another set of environment variables to run correctly, and once again, these should not be set when running the other 'flavors' of tests.

And all of our tests are based on JUnit, so using JUnit default settings is not a solution for me.

I haven't found a solution to this problem; and if there is one that I'm unaware of I'd greatly appreciate a pointer to it.

If not, I've had two ideas about possible solutions:
1) Adding additional applications for each of my test types under 'Defaults' on the Run/Debug Configurations page.  Similar to the JUnit application but with VM and Environment preset to the values we need.  I haven't found a built-in way to do this, so I'm wondering if this could be done via plugin.

2) A plugin that lets me store common run configurations for JUnit, and from a dialog box allow me to quickly select and set the JUnit defaults so that any time I use the Create or Debug option in the source context menu, it will create the test using the current Junit defaults that I selected.

The second option seems to me to be more universally useful.  A dialog box with a 'save' button to save the current JUnit settings with a named configuration, and a list selection with an 'apply' button to restore the settings.

Which leads me to the plugin.  This is my first plugin, and I've been reading through the documentation, but I have not been able to figure out how I should hook into the IDE to make this work.  I have managed to add a menu option under 'Run' to bring up my dialog, but the actual mechanics of hooking into the objects is stopping me.  One 'work-around' that feels prone to maintenance problems and future failure is to read the configuration xml and parse/update the information there, but I don't believe this file is documented, so relying on it's structure seems like a hack rather than a solution.

Can anyone give me some pointers at what I should be looking at to accomplish this task?

Thanks!

2 comments
Comment actions Permalink

Hi John,

There is very similar feature request at the issue tracker. Feel free to vote for it.

As for plugin development, I can't advice you a common solution but for your particular project you can create RunConfigurationExtension (and RunConfigurationExtensionManager as well) that could patch resulting running command depending on test type or some other things. You can find it here. Also there are couple implementations of these classes in intellij-community codebase, so it makes sense to clone the repository and check them out.

0
Comment actions Permalink

Thank you. I added my vote to that issue.  I will also checkout your other idea and see if I can make sense of it. (Understanding the Plugin API is non-trivial :) )

0

Please sign in to leave a comment.