Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij: Change JUnit Test Class template

I would like to customize the JUnit Test class template however I cannot find it anywhere in settings. This guy has the same problem. I can't find anything in File Templates or Live Templates. I'm using Intellij 11.

like image 844
shmish111 Avatar asked Feb 06 '13 10:02

shmish111


People also ask

How do I create a JUnit class in IntelliJ?

Right-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. Name the new method and press Enter .


2 Answers

This is now solved in the latest IntelliJ IDEA / Android Studio. Go to:

Settings -Editor -File and Code Templates -Code (tab) -JUnit4 Test Class  

edit the code in the right window.

Image of the dialog from above description

like image 102
Nilzor Avatar answered Sep 23 '22 08:09

Nilzor


The link provided by CrazyCoder suggests that this is not directly possible but that I you need to add if statements to the Class File Type template. I will probably split the template in two using a big if-else.

like image 22
shmish111 Avatar answered Sep 25 '22 08:09

shmish111