I tried run Parameterized Unit Test as below in Android Studio.
import android.test.suitebuilder.annotation.SmallTest;
import junit.framework.TestCase;
i
Kotlin DSL: add to your build.gradle.kts
tasks.withType<Test> {
useJUnitPlatform()
}
Gradle DSL: add to your build.gradle
test {
useJUnitPlatform()
}
Make sure you import the @Test
annotation from the correct library:
import org.junit.jupiter.api.Test
not
import org.junit.Test
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 image
(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.
You could check if your method is private. Spent a lot of time fixing this dumb mistake ...
I use @Test
annotiation of org.junit.Test
package, but I had the same problem. After adding testImplementation("org.assertj:assertj-core:3.10.0")
on build.gradle
, it worked.