Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Right click on a test does not present a "Run" option

In IntelliJ when I right click on a test I dont see a "Run ClassX or MethodY" anymore. Infact there is no "run" window and when I right click I cannot run any class.

It was all working fine about 3 hours ago so I am not quite sure what has changed?

IntelliJ 10.5.1 (Licensed and NOT community edition) Java 1.6.0_24

Is there anyone who could help me with this? PS: This happens for all projects.

UPDATE 1 I installed IDEA 11 and imported settings from 10 and then saw that it was not a free upgrade close IDEA 11 and started using IDEA 10. I am fairly certain things stopped working from that point but not sure. Is that a problem? Can I somehow delete IntelliJ configuration directory somehow and restart?

Adding a screenshot when I dont get Run option on right click enter image description here

like image 251
Kannan Ekanath Avatar asked Sep 06 '12 16:09

Kannan Ekanath


People also ask

How do I get the run option in IntelliJ?

From the main menu, select Run | Edit Configurations. Alternatively, press Alt+Shift+F10 , then 0 . on the toolbar or press Alt+Insert . The list shows the run/debug configuration templates.

Why run is not showing in IntelliJ?

In the same menu as the picture above 1 Click main toolbar then toolbar run actions. 2 At the "Toolbar Run Actions" leve, click the + button and "add action". 3 In the new popup, choose the "main menu" folder then the "run" folder. 4 Click on the "Run" icon and click ok.

Why run option is disabled in IntelliJ?

One possible problem is that the program is still running in the background and hasn't exited completely. Check your running processes for java applications and see if it exists. Or a variation - close Intellij window and reopen. That worked for me based on this tip.

How do I fix run configuration in IntelliJ?

Open the Run/Debug Configuration dialog in one of the following ways: Select Run | Edit Configurations from the main menu. With the Navigation bar visible (View | Appearance | Navigation Bar), choose Edit Configurations from the run/debug configuration selector. Press Alt+Shift+F10 and then press 0 .


2 Answers

If your project is a maven project then you can just right-click on the pom.xml file and select "add as Maven project".

This approach worked for me. (green plus third from the bottom)

enter image description here

like image 86
Guchelkaben Avatar answered Oct 18 '22 21:10

Guchelkaben


My problem was that my test class wasn't public. I needed:

public class MyTest {      @Test     public void testMethod() { 

instead of:

class MyTest {      @Test     void testMethod() { 
like image 22
GreenGiant Avatar answered Oct 18 '22 21:10

GreenGiant