Why is the Android test runner reporting “Empty test suite”?

前端 未结 30 2032
有刺的猬
有刺的猬 2020-11-28 07:59

I am banging my head against the wall here trying to figure out why IntelliJ/Android is reporting \"Empty test suite\". I have a small project with two IntelliJ Modules (\"

相关标签:
30条回答
  • 2020-11-28 08:19

    None of the other solutions worked for me, but I was able to get this working simply by uninstalling the existing app or test suite, then running the tests.

    0 讨论(0)
  • 2020-11-28 08:22

    In Android studio with spock framework I've changed my gradle's version from 2.2.2 to 3.2.1 and all goes well.

    0 讨论(0)
  • 2020-11-28 08:22

    I had this happen to me when I mistakenly marked a non mock class variable with the annotation @Mock Removed the annotation and the tests ran successfully. This happened with Junit 4.5 on Android Studio

    0 讨论(0)
  • 2020-11-28 08:23

    Here are my debugging steps I go through when Android Studio all of a sudden decides to stop running / debugging tests (And boy does this happen embarassingly often!!):

    • Build: → Rebuild project
    • Restart Device: Restart your device/emulator and try again
    • Device switch: if you have both a regular phone and an emulator unplug one and try running it with just one of the devices
    • Android Studio: File--> Invalidate caches and restart
    • Activity Monitor / Task Manager: sort processes by name, see if there is a nameless processes that's using up a lot of ram, this is a "ghost" process from Android studio that must be killed
    • git revert: try stashing /reverting your latest code. Sometimes there is a compile error that Android Studio / gradle misses and it will just try to run uncompilable code.
    • Uninstall then reinstall Android Studio.

    I will add more fixes as I run into them!

    0 讨论(0)
  • 2020-11-28 08:23

    In my case, I had my instrumented tests in androidTest/java/<package.name>/MyTestingClass, but I had set my current build variant to "preproduction". And there's the point! As specified in Android Studio documentation:

    By default, all tests run against the debug build type.

    The message Class not found. Empty test suite. kept appearing until I did this:

    1. Add this line to my build.gradle:

      android{
          [...]
          testBuildType "preproduction"
      }
      
    2. Synchronised gradle.
    3. Delete my previous test configurations since they don't take this Gradle synchronisation into account.

    Then I executed the tests again and this time they run just perfect!!!

    0 讨论(0)
  • 2020-11-28 08:25

    None of the above fixed it for me. What helped was following the instructions:

    Create a test configuration

    In Android Studio:

    • Open Run menu -> Edit Configurations
    • Add a new Android Tests configuration
    • Choose a module
    • Add a specific instrumentation runner:

      android.support.test.runner.AndroidJUnitRunner

    Run the newly created configuration.

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