Trying to do TDD in a java project using groovy tests, I need to generate java classes on the fly (Alt+
Enter from the test on the name of a class I want to introduce -> Create class -> Select the java main package as Target destination).
The problem is that, even if the Target destination is a java source directory, IntelliJ generates a groovy class.
Is there any way to quickly generate a Java class, instead?
Create a new test class manuallyRight-click the test root folder or package in the test root folder in which you want to create a new test and select New | Java Class. Name the new class and press Enter . Press Alt+Insert and select Test Method to generate a new test method for this class.
In the Project tool window, right-click the project and from the context menu, select Add Framework Support. In the dialog that opens, select Groovy and click OK. IntelliJ IDEA adds the Groovy SDK to your project and you can add Groovy classes and Groovy scripts.
In the Project tool window ( Alt+1 ), right-click the node in which you want to create a new class and select New | Java Class. Alternatively, select the node, press Alt+Insert , and select Java Class.
With the current version of IntelliJ IDEA (2016.2.4) the only solution I found is to generate a groovy class (Alt+
Enter| Create class
from the test) and then convert it to Java (Refactor | Convert to Java
).
To make it faster I also added a shortcut for Convert to Java
: Ctrl+Shift+O was the best available option for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With