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

前端 未结 30 2151
有刺的猬
有刺的猬 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条回答
  •  -上瘾入骨i
    2020-11-28 08:32

    In my case, the project I was working on had a couple of modules. None of the solutions I found for this error helped me, and then somehow I realized that if I added the testing dependencies in BOTH of the build.gradle files, the tests magically started working. It doesn't matter if your tests live in only 1 of the modules, both gradle files must include the dependencies and the testInstrumentationRunner value.

    So, if like me, none of the other answers have helped you, try adding these lines to the build.gradle file of each of your modules:

    android {    
        ....
        defaultConfig {
            ...
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }  
    }
    

    and then also add:

    dependencies {
        ...
        // Test
        androidTestCompile 'com.android.support:support-annotations:23.4.0'
        androidTestCompile 'com.android.support.test:runner:0.5'
        androidTestCompile 'com.android.support.test:rules:0.5'
    
    }
    

提交回复
热议问题