Just out of interest - why has it been decided to move tests to a separate project, not just to a separate source folder?

Question author Eugene | Source



The test application "instruments" the target or main application.

The instrumentation section in the test project's AndroidManifest.xml allows the tests to run in the same process as the application. This instrumentation feature allows the test application to step through android component lifecycles in a controlled way.

Having this control allows you to (for example) create repeatable tests for cases for the activity lifecycle (create,resume,pause,destroy).

see http://developer.android.com/guide/topics/testing/testing_android.html#Instrumentation

So in summary, the extra application has special powers over the test target. Since these are encapsulated in the test application, your real application need only have the permissions it requires to perform its duty.

Answer author Byeo

Ask about this question here!