1

I am a novice to Android development. I am looking into 'how to set up a test environment in Android Studio'. So, here is my question;

As per the official Android training source (https://developer.android.com/training/testing/unit-testing/local-unit-tests.html) says, In your app's top-level build.gradle file, you need to specify these libraries as dependencies:

enter image description here

But in my case, am using Android Studio Version 2.2.3 and it shows two build.gradle files i.e., build.gradle ( Project: name ) and build.gradle ( Module: app ), out of which one already had the dependencies mentioned by default and the other doesn't. Please look at following pictures for understanding.

build.gradle ( Project: name ) enter image description here

build.gradle ( Module: app ) enter image description here

Where should the dependencies be mentioned?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • 2
    Possible duplicate of [Why are there two build.gradle files in an Android Studio project?](http://stackoverflow.com/questions/23241681/why-are-there-two-build-gradle-files-in-an-android-studio-project) – Juan Cruz Soler Jan 13 '17 at 13:56
  • My question is not specifically about why but where the dependencies to be mentioned. –  Jan 13 '17 at 14:02
  • Place them in your app build.gradle (second screenshot) – Juan Cruz Soler Jan 13 '17 at 14:08
  • @JuanCruzSoler Thank you for the response. But it shows the dependency by default regards Junit. So, no more edit required in setting up new android projects. Am I right? –  Jan 13 '17 at 14:12
  • You are right, junit dependency is added by default. But mockito is not – Juan Cruz Soler Jan 13 '17 at 19:35
  • @JuanCruzSoler Just curious to know what's the difference with Project and Module in this scenario. Could you please state with a practical example? Isn't it better to have dependencies in Project Gradle build file as when we hit Run, it does unit testing for all classes in entire project? –  Jan 17 '17 at 20:41

0 Answers0