Android Studio
Unit Testing
Parameterized Tests
No Tests Found Error
Debugging

No tests found for given includes Error, when running Parameterized Unit test in Android Studio

Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms

Introduction

“No tests found for given includes” usually means Android Studio launched Gradle with a filter that did not match any discoverable test method. With parameterized tests, the problem is often a mismatch between the JUnit version, the test runner, the source set, or the run configuration that Android Studio generated. The fix is to make sure the parameterized test is written for the runner your module is actually using.

Start with the Correct Test Type

For local JVM unit tests, the file belongs in app/src/test/java or app/src/test/kotlin. For instrumentation tests that run on a device or emulator, it belongs in app/src/androidTest/....

A JUnit 4 parameterized local unit test in Kotlin looks like this:

kotlin
1import org.junit.Assert.assertEquals
2import org.junit.Test
3import org.junit.runner.RunWith
4import org.junit.runners.Parameterized
5
6@RunWith(Parameterized::class)
7class SumTest(private val a: Int, private val b: Int, private val expected: Int) {
8
9    @Test
10    fun addsCorrectly() {
11        assertEquals(expected, a + b)
12    }
13
14    companion object {
15        @JvmStatic
16        @Parameterized.Parameters(name = "{0} + {1} = {2}")
17        fun data(): Collection<Array<Int>> = listOf(
18            arrayOf(1, 2, 3),
19            arrayOf(2, 3, 5),
20            arrayOf(5, 8, 13)
21        )
22    }
23}

This requires JUnit 4 on the unit-test classpath.

Check Dependencies and Runner Assumptions

For the example above, your module should include JUnit 4:

gradle
dependencies {
    testImplementation 'junit:junit:4.13.2'
}

If the project uses JUnit 5, the setup is different. Mixing JUnit 4 annotations with a JUnit 5 engine or vice versa is a common reason tests are not discovered.

If you are in androidTest, then @RunWith(Parameterized::class) for a plain local JVM runner may not match the instrumentation setup you expected.

Android Studio Run Configurations Can Go Stale

Sometimes the code is correct, but Android Studio cached a run configuration that filters to a method name or old class signature that no longer exists. Deleting the run configuration and running the test class again from the gutter often fixes it.

Another reliable check is to run the Gradle task directly:

bash
./gradlew testDebugUnitTest --tests "*SumTest"

If Gradle finds the test but Android Studio does not, the IDE configuration is usually the problem.

Verify the Test Method Signature

In Java-based JUnit 4 tests, the test method should be public, return void, and be annotated with @Test. Kotlin is less verbose here, but the method still needs to be discoverable by the runner. A parameterized class with no valid test method will also surface as a “no tests found” style failure.

Parameterized Tests Need Discoverable Structure

Make sure:

  • the test class is not abstract
  • the test method is annotated with @Test
  • the parameter provider is valid for the JUnit version in use
  • the file sits in the correct source set
  • the module dependency includes the right test library

A small mismatch in any of those pieces can lead to a discovery failure that shows up as “no tests found.”

Common Pitfalls

  • Writing a JUnit 4 parameterized test while the project is configured for JUnit 5 only.
  • Putting a local unit test under androidTest instead of test.
  • Using a stale Android Studio run configuration with outdated filters.
  • Forgetting @RunWith(Parameterized::class) for a JUnit 4 parameterized class.
  • Expecting instrumentation runners and local JVM test runners to behave the same way.

Summary

  • The error usually means the test runner could not discover any matching test.
  • Verify the source set, JUnit version, and parameterized runner all match.
  • Use JUnit 4 setup for @RunWith(Parameterized::class) tests.
  • Run the test from Gradle to separate IDE issues from test-framework issues.
  • If Android Studio still fails, recreate the run configuration.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms