javaunit-testingintellij-idea

Create Test Class in IntelliJ


I'm working within the traditional Maven Java project structure inside IntelliJ, e.g.

main/java/com/x/y
test/java/com/x/y

When I create a class called Foo in main/java/com/x/y using IntelliJ I would like to automatically have a file called FooTest.java created in test/java/com/x/y.

In Eclipse there is a button on the toolbar that will do much of the work involved in creating a skeleton test class, does anyone know of something similar in IntelliJ?


Solution

  • Use the menu selection Navigate -> Test, or Ctrl+Shift+T (Shift+āŒ˜+T on Mac). This will go to the existing test class, or offer to generate it for you through a little wizard.