IntelliJ IDEA 2018.1 Help

Creating Tests

You can create test classes for the supported testing frameworks using the intention action.

  1. Open the necessary class in the editor and place the cursor on a class name.
  2. Press Alt+Enter to invoke the list of available intention actions.
  3. Select Create Test.
    createTest1.png

    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.

  4. 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.

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 the File | Settings/Preferences | Editor | Code Style | Java dialog on 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.

Last modified: 4 April 2018

See Also

Language and Framework-Specific Guidelines: