Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

What is useJUnitPlatform?

useJUnitPlatform() Specifies that JUnit Platform should be used to discover and execute the tests.

Which Java framework is used to write unit tests in android?

JUnit is a “Unit Testing” framework for Java Applications which is already included by default in android studio. It is an automation framework for Unit as well as UI Testing. It contains annotations such as @Test, @Before, @After, etc.


Add to your build.gradle:

test {
    useJUnitPlatform()
}

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


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/


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

tasks.test {
    useJUnitPlatform()
}