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

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

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


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


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

Every keyword in the above statement is critical. If you omit one, IntelliJ wont' recognize it. Easy-to-forget keywords are static, void, and the String[] args argument.

I had forgotten the arguments in mine ;-)

Also make sure your source code is inside a src folder which is marked as such by IntelliJ.