Explain Codes LogoExplain Codes Logo

Class Not Found: Empty Test Suite in IntelliJ

java
intellij
debugging
testing
Alex KataevbyAlex Kataev·Feb 2, 2025
TLDR

To fix the "Class Not Found: Empty Test Suite" issue, make sure your test classes reside in src/test/java folder, typically ending with Test. In IntelliJ, validate your test framework under Project Structure > Modules > Dependencies. Include JUnit or TestNG if missing.

For JUnit 5, make sure JUnit Jupiter API and Engine are set up correctly. Use the @Test annotation correctly. If the error continues, consider Invalidate Caches / Restart in IntelliJ.

Here's an example for a JUnit 5 test:

import org.junit.jupiter.api.Test; class ExampleTest { @Test void testMethod() { // Your coffee machine ... eh, I mean test goes here... } }

Troubleshooting your setup

Tests refusing to show up? Calm down and start troubleshooting. Here are some actionable steps:

Introduce your project to IntelliJ again

In some scenarios, IntelliJ loses track of what's where. In both Maven and Gradle projects, you may find re-importing helpful.

Say yes to output paths and build folders.

Double-check your module output paths under File > Project Structure > Modules > Paths. 'Exclude output path' option should not be selected. The art of debugging is a delicate hunt, inspect your build folders carefully for compiled .class files.

Getting along with annotations and language levels

Incorrect annotations or a mismatched language level could give birth to elusive bugs. Protect the life of your code by ensuring your language level matches your JDK.

Plugin talks

Working with Kotlin? You need plugins like 'kotlin-android'. Validate their presence and compatibility in File > Project Structure > Global Libraries.

Trying harder

Controlled desperation is just the start of a good debugging session. Let's go deeper!

Setting up test sources

Test classes absent in test execution? Check your test source roots. Use right-click > Mark Directory as > Test Sources Root on the test folder.

Clean slate approach

Old states might corrupt new runs. Consider wiping out IntelliJ's memory by deleting the run/debug configuration. Run > Edit Configurations... > -

Dependencies and plugins check

Cross-check the availability of all testing dependencies in your project files. Repositories like maven-surefire-plugin or gradle-test-logger-plugin can be handy.

Don't shy away from revealing a detailed error log or sequencing your steps; it enhances the community's ability to help.