Fletcher
Fletcher

Reputation: 641

Intellij : Adding 'JUnit' to context menu when creating new file

Currently in Intellij if I try to create a new file via "New > whatever", I don't see any option to choose a JUnit file. I dug deeper and found out the "Edit File Templates...". While you can add a variety of files from there to the context menu, there is no ability to choose JUnit.

enter image description here

If you browse over to "Code" tab you can see various JUnit templates. However I have no idea if these are just code generation templates instead of file generation templates. And besides, there is no option to port them to the "Files" tab.

The closest SO thread describing this issue is this and it failed to match my needs.

Mind you I am relatively new to Intellij and I come from eclipse.

P.S: I am aware you can generate tests from existing classes. I am currently trying to implement TDD so that does not answer my needs.

Upvotes: 0

Views: 247

Answers (1)

Mureinik
Mureinik

Reputation: 312319

While I don't have an answer for this exact question, I think there's an easier way to handle the underlying requirements (easily creating tests):

Navigate to the class you want to test and press ALT+ENTER. In the context menu, pick "Create Test":

Create Test context menu

After you choose it, you'll get a dialog with several options including the framework to use (e.g., JUnit 5, JUnit 5, TestNG), the methods you want to generate test stubs for, etc:

Test generation menu

Upvotes: 1

Related Questions