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

前端 未结 17 2009
孤独总比滥情好
孤独总比滥情好 2021-01-31 07:03

I tried run Parameterized Unit Test as below in Android Studio.

import android.test.suitebuilder.annotation.SmallTest;  

import junit.framework.TestCase;    

i         


        
相关标签:
17条回答
  • 2021-01-31 07:33

    Kotlin DSL: add to your build.gradle.kts

    tasks.withType<Test> {
            useJUnitPlatform()
    }
    

    Gradle DSL: add to your build.gradle

    test {
        useJUnitPlatform()
    }
    
    0 讨论(0)
  • 2021-01-31 07:38

    Make sure you import the @Test annotation from the correct library:

    import org.junit.jupiter.api.Test

    not

    import org.junit.Test

    0 讨论(0)
  • 2021-01-31 07:38

    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.

    0 讨论(0)
  • 2021-01-31 07:38

    You could check if your method is private. Spent a lot of time fixing this dumb mistake ...

    0 讨论(0)
  • 2021-01-31 07:38

    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.

    0 讨论(0)
提交回复
热议问题