title: Writing Gradle script to run unit test cases for Eclipse Android Test project
body: <p>I have a simple HelloWorld Android project (built in Eclipse IDE), I am able to do "gradle build" successfully in cmd prompt for this project.</p>
  
  <p>Also I have written a simple JUnit Android Test Project for it, and it runs fine in Eclipse.</p>
  
  <p>Now I want to run this Test Project or Unit Test Cases (if my understanding is wrong!) using Gradle script.
      How do I do that?</p>
  
  <p>Following is the build.gradle file I am using. I want to know how to write script code to automate the test case execution.</p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.10.+'
      }
  }
  apply plugin: 'android'
  
  dependencies {
      compile fileTree(dir: 'libs', include: '*.jar')
  }
  
  android {
      compileSdkVersion 19
      buildToolsVersion "19.0.3"
  
      sourceSets {
          main {
              manifest.srcFile 'AndroidManifest.xml'
              java.srcDirs = ['src']
              resources.srcDirs = ['src']
              aidl.srcDirs = ['src']
              renderscript.srcDirs = ['src']
              res.srcDirs = ['res']
              assets.srcDirs = ['assets']
          }
          test {
              java.srcDirs = ['src/test/java']
              resources.srcDirs = ['src/test/resources']         
          }
  
          // Move the tests to tests/java, tests/res, etc...
          instrumentTest.setRoot('tests')
          androidTest.setRoot('tests')
  
          // Move the build types to build-types/&lt;type&gt;
          // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
          // This moves them out of them default location under src/&lt;type&gt;/... which would
          // conflict with src/ being used by the main source set.
          // Adding new build types or product flavors should be accompanied
          // by a similar customization.
          debug.setRoot('build-types/debug')
          release.setRoot('build-types/release')
      }
  }
  </code></pre>