Test package for different flavors in Android Studio

后端 未结 2 877
独厮守ぢ
独厮守ぢ 2021-02-07 05:21

I am experimenting flavors on an application in androidstudio. I have to write different test classes for the flavors, as I have different class files for the flavors. But I won

相关标签:
2条回答
  • 2021-02-07 05:25

    From the documentation

    Testing multi-flavors project is very similar to simpler projects.

    The androidTest sourceset is used for common tests across all flavors, while each flavor can also have its own tests.

    As mentioned above, sourceSets to test each flavor are created:

    • android.sourceSets.androidTestFlavor1
    • android.sourceSets.androidTestFlavor2

    So, just as you should have now 'free' and 'paid' folders with code specific for each flavor, you can add 'androidTestFree' and 'androidTestPaid' folders where you you can add test cases specific to each one of your flavors.

    0 讨论(0)
  • 2021-02-07 05:48

    This is really what did it for me: How to specify unit test folder in two-dimension flavor

    dependencies {
      androidTestFlavor1Compile "..."
    
      //In your case androidTestStbAppleCompile         
    }
    
    0 讨论(0)
提交回复
热议问题