Confused about testCompile and androidTestCompile in Android Gradle

前端 未结 4 877
后悔当初
后悔当初 2020-11-30 20:53

I\'m new to testing world and even more to Android testing world. While doing research on Robolectric that aids with tests on android one thing confuses me the most. Sometim

4条回答
  •  一整个雨季
    2020-11-30 21:40

    Simply testCompile is the configuration for unit tests (those located in src/test) and androidTestCompile is used for the test api (that located in src/androidTest). Since you are intending to write unit tests, you should use testCompile.

    Update: The main distinction between the two is the test sourceset runs in a regular Java JVM, whereas the androidTest sourceset tests run on an Android device (or an emulator).

提交回复
热议问题