Ho un semplice progetto HelloWorld per Android (costruito in Eclipse IDE), sono in grado di eseguire "gradle build" correttamente nel prompt cmd per questo progetto.Scrittura dello script Gradle per eseguire test case unit per il progetto Test di Eclipse Android
Inoltre, ho scritto un semplice progetto di test di JUnit per Android e funziona perfettamente con Eclipse.
Ora voglio eseguire questo Test Project o Unit Test Cases (se la mia comprensione è sbagliata!) Utilizzando lo script Gradle. Come faccio?
Di seguito è riportato il file build.gradle che sto utilizzando. Voglio sapere come scrivere codice script per automatizzare l'esecuzione del test case.
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/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... 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')
}
}
'instrumentTest' è stato rinominato in' androidTest', vedere Cronologia per https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.enide .editors.gradle/docs/android/build.gradle –