Create Test Class in IntelliJ

Scruffers picture Scruffers · Dec 3, 2010 · Viewed 104.9k times · Source

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?

Thanks,

Answer

Jarl picture Jarl · Dec 3, 2010

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.