views:

52

answers:

2

I am wanting to set up a Run/Debug Configuration in IntelliJ for JUnit. I know how to set it up to run a specific package, a specific class, or a specific method. I was wondering if there was a way to set up the configurations so it will run the currently opened Class file or the currently selected test method. I would imagine I would put something like this in the Class field of the Run/Debug Configurations dialog box:

my.package.tests.${currentTest}

or something like that. Is there a way to accomplish this so I don't have to make a Run/Debug Configuration for each test class I want to run?

+1  A: 

You can either use the right-click > "run testYourtest()" or the shortcut define in the keymap as "Run context configuration".

Usually it's ctrl + shift + F10.

Colin Hebert
so I don't have to add a new configuration in the Run/Debug Configuration?
Joel
No you don't have to
Colin Hebert
+2  A: 

If you need specific settings for all you tests you can change the defaults e.g. add -ea. This way you don't need a configuration for each test.

BTW: YoU can run all the tests in a package, by selecting the package first. Sometimes it is better to run a group of tests to check you haven't changed something unintended.

Peter Lawrey
+1 for the reference to change in defaults
Jayan