Execute all tests from the command line with 
Gradle

Follow these instructions to build the application, resolve dependencies, run the tests on a connected 
Android
 device, and record the results. This command can be run from a continuous integration system such as Jenkins.
  1. Change the directory to samples/
    <app_name>
    .
  2. Run the following command: 
    ./gradlew connectedAppDebugAndroidTest
Test results are written to the following sub-directory: 
<app_name>
/build/reports/androidTests/connected/flavors/APP.
You can save test results using a continuous integration system. You can also use a JUnit plug-in to display the test results in a readable form, to send email messages to project members, or to take other common continuous integration actions.
For more information about running tests using the command line, see Android Studio: Test from the command line.