Skip to content

Java – intelliJ – generate test files with an extra line after the closing “}”?

Small question regarding IntelliJ, and the generate (test) file feature.

Benign question, currently, after creating a class, in IntelliJ, there is an option to create a corresponding test class. (Right click -> show action context -> generate test class)

The generated file is just a skeleton:

package some.package;

import static org.junit.jupiter.api.Assertions.*;

class TheClassTest {


All of the classes usually ends up with an extra end of line file.


Even static analysis tools will flag it if not present (“missing end of file” something like that).

My question is not to make static analysis tools happy, but rather to stay in sync with the so many classes and non generated test files, all with the extra line at the end of file.

How to tell IntelliJ to generate the test classes with the extra line at the end of the file please?

Thank you



Each generated class is based on the exact template. In the settings, you can update the template and add a new line to it.

Setting -> Editor -> File and Code Templates -> Code tab -> JUnit5 Test Class

Now you add a new line to the template and all newly generated test classes will have it.

User contributions licensed under: CC BY-SA
6 People found this is helpful