Running groovy unit tests from hotkey

When I'm using Java + Junit style tests, I'm able to just hit Ctrl + Shift + F9 (Run) to cause Intellij to run the method currently under the cursor to be executed as a test.

This is extremely convenient, and it's made me quite happy....

Now I'm using for the first time Groovy to write TestNG tests, and hitting  Run causes the groovy script to be run as a script, not as a test.  I can't find any straightforward, hotkey centric way to cause the groovy method to be executed as a test.

Anyone have any suggestions?

Thanks,
Seth

4 comments
Comment actions Permalink

CtrlShiftF10?

Could you provide an example of your Groovy TestNG test case?

0
Comment actions Permalink

Yes, Ctrl Shift F10.  I use F9 alot for debug, sorry for the confusion.

Anyway, this simple DummyTest.groovy would highlight the problem.

package some.package

import org.testng.annotations.Test
import static org.testng.Assert.assertEquals


@Test
void testEquals() {
  assertEquals(1, 1, "The answer should be one");
}



If you put your cursor on the assertEquals(1, 1, "The answer should be one"); line, and hit CtrlShiftF9 or F10, you should see that no test is run.. instead, a groovy script is executed.

Thanks for the help,
Seth

0
Comment actions Permalink

Currently we do not support running such methods that aren't contained
in an explicit class, sorry. You should place the test method to a class .

0
Comment actions Permalink

A simple enough workaround.  I can't live without my hotkeys

Thanks Peter,
Seth

0

Please sign in to leave a comment.