I have our project building using Gradle. I am now trying to add our tests to the build. I am not totally sure how this works, or what the actuall syntax to use would be.
Here is the build script for a test application I have been trying to get working. My tests are in the src/instrumentTest/java directory.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
testPackage "com.example.myapplication.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
}
When I do a build I get the following error.
FAILURE: Build failed with an exception.
Where: Build file '/Users/kbrown/AndroidStudioProjects/MyApplicationProject/MyApplication/build.gradle' line: 22
What went wrong: A problem occurred evaluating project ':MyApplication'.
Could not find method testPackage() for arguments [com.example.myapplication.test] on ProductFlavorDsl_Decorated{name=main, minSdkVersion=8, targetSdkVersion=16, renderscriptTargetApi=-1, versionCode=-1, versionName=null, packageName=null, testPackageName=null, testInstrumentationRunner=null, signingConfig=null}.