I use the Gradle IDE plugin for Eclipse and I created a custom task in the build.gradle file:
sourceSets {
unitTest {
java.srcDirs = ['tests']
}
}
dependencies {
unitTestCompile files("$project.buildDir/classes/debug")
unitTestCompile 'junit:junit:4.11'
unitTestCompile 'org.robolectric:robolectric:2.1.1'
unitTestCompile 'com.google.android:android:4.0.1.2'
}
configurations {
unitTestCompile.extendsFrom runtime
unitTestRuntime.extendsFrom unitTestCompile
}
task unitTest(type:Test, dependsOn: assemble) {
description = "run unit tests"
testClassesDir = project.sourceSets.unitTest.output.classesDir
classpath = project.sourceSets.unitTest.runtimeClasspath
}
build.dependsOn unitTest
The problem is that the links I referenced are not added in Eclipse and I get the error that import org.junit.Test;, import org.robolectric.Robolectric;etc. cannot be allowed. I tried right-clicking on the project -> Gradle -> Update Dependencies, but to no avail.
source
share