Execute specific tests from the command line with 
Gradle

Follow these instructions to build the application, resolve dependencies, run the tests in the specified class on a connected 
Android
 device, and record the results.
  1. Change the directory to samples/
    <app_name>
    .
  2. Run the following command: 
    ./gradlew connectedAppTestDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=<className>
    Replace 
    <classname>
     with the name of your class.
You can also run a specific test manually using the following method:
  1. Use 
    Gradle
     to build the 
    androidTest
     target.
  2. Use the 
    Android
     Debug Bridge (ADB) tool to install the app from the resulting .apk file. You can choose to uninstall any existing app first or to install as an upgrade.
  3. Execute specific test suites or individual tests using the ADB tool, with a command such as: 
    adb shell am instrument -w -e debug false -e class <packageName>.<className> <packageName>.test/testRunner
    Replace 
    <packagename>
     and 
    <classname>
     with values for your app and class.
Test results are written to the following sub-directory: 
<app_name>
/build/reports/androidTests/connected/flavors/APPTEST.
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.