lopez.mikhael lopez.mikhael - 1 year ago 77
Android Question

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

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

The first is

. This folder already existed on the previous version of Android Studio. Nevertheless, since some time, there is a new test folder by default
and new dependence
testCompile 'junit: junit: 4.12'

My question is: Which folder I use for testing and the differences between the two?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download