Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default test class name suffix in Intellij IDEA

By default when I generate test class in IDEA it has "Test" suffix. As I usually use Spock I want to change it to be "Spec" by default. Is it somehow possible?

like image 666
Jakub Kubrynski Avatar asked Feb 06 '16 23:02

Jakub Kubrynski


People also ask

How do I change class name in IntelliJ?

From the context menu, select Refactor | Rename ( Shift+F6 ). In the popup that opens, select what you want to rename. If you have a module with one content root, and it has the same name as your module, you can rename them both simultaneously. In the Rename <name> dialog that opens, add the new name and click OK.

How do I mark a class as test in IntelliJ?

In your production code in the editor, place the caret at the class for which you want to create a test, press Alt+Enter , and select Create Test. In the Create Test dialog, select the library that you want to use. If you don't have the necessary library yet, you will be prompted to download it. To do that, click Fix.

Where is Test class in IntelliJ?

You can use ⇧⌘T (macOS), or Ctrl+Shift+T (Windows/Linux), to navigate to a test class and back again.


1 Answers

It's finally possible with the IntelliJ 2018.1:

With the IntelliJ IDEA 2018.1, you can customize a test class template and create a test class with Test as a prefix. Go to Preferences | Editor | Code Style | Java | Code Generation, and choose how the test class name should be generated. By default, the IDE creates a test class with the Test as a suffix.

Above is from this blog post

like image 128
Jakub Kubrynski Avatar answered Sep 17 '22 19:09

Jakub Kubrynski