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

Solution 1:

Add to your build.gradle:

test {
    useJUnitPlatform()
}

Solution 2:

If you're using JUnit 5+, make sure you import the @Test annotation from the correct library:

import org.junit.jupiter.api.Test

not

import org.junit.Test

Solution 3:

I am using JUnit 4, and what worked for me is changing the IntelliJ settings for 'Gradle -> Run Tests Using' from 'Gradle (default)' to 'IntelliJ IDEA'.

enter image description here

Source of my fix: https://linked2ev.github.io/devsub/2019/09/30/Intellij-junit4-gradle-issue/

Solution 4:

To add to already great and easy solution provided by Przemek315, the same config if you use Kotlin DSL:

tasks.test {
    useJUnitPlatform()
}

Solution 5:

Found a way to run the test in Android Studio. Apparently running it using Gradle Configuration will not execute any test. Instead I use JUnit Configuration. The simple way to do so is go to Select your Test Class to run and Right Click. Then choose Run. After that you'll see 2 run options. Select the bottom one (JUnit) as per the imageenter image description here

(note: If you can't find 2 Run Configuration to select, you'll need to remove your earlier used Configuration (Gradle Configuration) first. That could be done by Clicking on the "Select Run/Debug Configuration" icon in the Top Toolbar.