Creating Tests
You can create test classes for the supported testing frameworks using the intention action.
Open the necessary class in the editor and place the cursor on a class name.
Press Alt+Enter to invoke the list of available intention actions.
-
Select Create Test.
Alternatively, you can place the cursor on the class name and select Navigate | Test from the main menu, or select Go to | Test from the shortcut menu, and click Create New Test.
In the Create Test dialog, configure the required settings. You can specify a testing library you want to use, configure a test class name and its location, and select methods for which you want to generate test classes.
Create test methods
To create stub test methods in JUnit test classes, you can use the IntelliJ IDEA code generation feature.
Open the corresponding JUnit test class in the editor.
Place the cursor where you want a new test method to be generated.
Press Alt+Insert and select Test Method from the Generate menu.
Configure naming pattern for generated test classes
By default, IntelliJ IDEA attaches the Test
suffix to source class names when it automatically generates test classes. You can change the naming pattern for test classes.
In Settings/Preferences (Ctrl+Alt+S, go to , and open the Code Generation tab.
In the Naming section of the tab, type a suffix or a prefix (or both) that you want to use for naming generated test classes into the corresponding fields.