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


Solution 1:

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

Solution 2:

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() {

Solution 3:

I had the same problem. To fix it, I had to ensure that my class had a proper main method:

public static void main(String[] args) {
}

I had forgotten the arguments in mine ;-)

EDIT: Make sure your source codes are inside a src folder.

Solution 4:

In my case, the cause was disabled JUnit plugin. (File — Settings — Plugins — JUnit, check, OK)