title: Run JUnit tests in Gradle for Android app
body: <p>I want to run simple, plain JUnit tests in my Android app project, using Gradle at the same time to write Activity tests afterwards. It took a loong time to configure Gradle and make it work, but, anyway, now I'm stuck trying to make JUnit tests just compile.</p>
  
  <p>I checked this <a href="http://robertomurray.co.uk/blog/2013/run-junit-tests-with-gradle-android/">link</a>, but when I run gradle I get the following error:</p>
  
  <pre><code>DummyTest.java:3: error: package junit.
  framework does not exist
  import junit.framework.Assert;
                        ^
  \DummyTest.java:8: error: cannot find symbol
          Assert.assertEquals(5,3);
          ^
    symbol:   variable Assert
    location: class DummyTest
  </code></pre>
  
  <p>So, junit is not found...</p>
  
  <p>The following is my full gradle.build file:</p>
  
  <pre><code>    buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.6.+'
      }
  }
  apply plugin: 'android'
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile files('libs/joda-time-2.3.jar')
      compile files('libs/android-support-v4.jar')
      unitTestCompile files("$project.buildDir/classes/release")
      unitTestCompile 'junit:junit:4.8.2'
  }
  
  android {
      compileSdkVersion 17
      buildToolsVersion '17.0.0'
  
      sourceSets {
          main {
              manifest.srcFile 'AndroidManifest.xml'
              java.srcDirs = ['src']
              resources.srcDirs = ['src']
              aidl.srcDirs = ['src']
              renderscript.srcDirs = ['src']
              res.srcDirs = ['res']
          }
  
          unitTest {
              java.srcDir file('test')
              resources.srcDir file('test/res')
          }
      }
      defaultConfig {
          minSdkVersion 14
          versionName '1.0'
          versionCode 1
          targetSdkVersion 17
      }
  }
  
  // add the unitTest task
  task unitTest(type:Test, dependsOn: assemble) {
      description = "run unit tests"
      testClassesDir = project.sourceSets.unitTest.output.classesDir
      classpath = project.sourceSets.unitTest.runtimeClasspath
  }
  
  build.dependsOn unitTest
  </code></pre>