Coding⏱️ 2 min read📅 2026-05-31

How to Fix: java.lang.Exception: No runnable methods exception in running JUnits

The issue is caused by the missing @RunWith annotation on the TestRunner class. Add @RunWith(JUnitCore.class) to the TestRunner class.

Quick Answer: Add @RunWith(JUnitCore.class) to the TestRunner class to fix the exception.

To resolve the 'java.lang.Exception: No runnable methods' exception when running JUnit tests, you need to ensure that your test class contains a main method or a @RunWith annotation.

🔍 Why This Happens

  • [Cause]

🚀 How to Resolve This Issue

Method 1: Using a Main Method

  1. Step 1: Add a main method to your test class that calls the JUnitCore.

Method 2: Using @RunWith Annotation

  1. Step 1: Annotate your test class with the @RunWith annotation and specify JUnitCore as the runner.

🎯 Final Words

By implementing one of these methods, you can resolve the 'java.lang.Exception: No runnable methods' exception and successfully run your JUnit tests.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions