[FIXED] What's the difference between src/androidtest and src/test folders?


In a project, in Android Studio, by default, there are two test folders.

The first is src/androidTest. This folder already existed in the previous version of Android Studio. Nevertheless, there is now a new test folder, by default, src/test, and new dependence, testCompile 'junit: junit: 4.12' in build.gradle.

Which folder do I use for testing? What are the differences between the two?


src/androidTest is for unit tests that involves android instrumentation.

src/test is for pure unit test that do not involve android framework. You can run tests here without running on a real device or on emulator.

You can use both folders. Use the first one to test code that use Android framework. Use the second one to test code that are pure java classes. The methods to write tests are almost the same.

More info here : http://developer.android.com/tools/testing/testing_android.html

Answered By – Bipi

Answer Checked By – Marilyn (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published