Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

intelliji or android studio - short cut to create method test case

Is there a short cut to create a test method quickly in IntelliJ? What I want to happen is if I already have a test class called TestClass, then in my Class file if I create a new method I could right click on the new method and click something like 'create test' on the method itself. There is an option available for the class but I can't see it for the method level. Take a look at this photo and you'll see that the option is available for the class(by pressing alt + enter), but I'd like it available for the method also.

on the class level

UPDATE: It seems the option might be in IntelliJ but I cannot find this in Android Studio 1.1. When I hit alt+enter on a method in android studio (where the hosting class already has a test case) I get this menu:

enter image description here

and here is the funny thing in android studio, if I go into the test case class itself then I see an option to create test method within that class. It's just not showing up in the concrete class I need to be tested:

enter image description here

like image 713
j2emanue Avatar asked Feb 15 '15 01:02

j2emanue


People also ask

How do I create a test method in IntelliJ?

Right-click the test root folder or package in the test root folder in which you want to create a new test and select New | Java Class. Name the new class and press Enter . Press Alt+Insert and select Test Method to generate a new test method for this class. Name the new method and press Enter .

How do I create a test class shortcut in IntelliJ?

Press ⇧⌘T (macOS), or Ctrl+Shift+T (Windows/Linux), to create the new Test class (or navigate to an existing Test class).


1 Answers

Android Studio Ctrl+Shift+T or Navigate->Test.

like image 138
Honghe.Wu Avatar answered Oct 12 '22 06:10

Honghe.Wu