Reputation: 681
I recently decided to switch from Eclipse to Android Studio. While i was able to import my android project, i keep having problems setting up and transfering my unit tests. For testing purposes i made a directory in src folder (java folder and test package). For enabling robotium i followed another stack topic by adding androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
. Eventually i added my test java file from Eclipse. And when i try to run tests, i keep getting "Cannot resolve symbol Solo".
I have little understanding about how AS and gradle works, so probably i am missing something else. The contents of my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.colormindapps.work_rest__scheduler"
minSdkVersion 8
targetSdkVersion 21
testApplicationId "com.colormindapps.work_rest__scheduler.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/tests/java']
}
}
}
dependencies {
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
compile 'com.android.support:support-v4:19.0.+'
compile 'com.android.support:appcompat-v7:19.0.+'
}
Upvotes: 4
Views: 3577
Reputation: 1634
Use androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.5.4' which resolve all test cases issues
Upvotes: 1
Reputation: 5332
You must use separate source set for you android-specific tests, i.e.:
sourceSets {
main {
java.srcDirs = ['src/main/java']
}
androidTest {
java.srcDirs = ['src/tests/java']
}
}
Upvotes: 1
Reputation: 1919
I think the easiest way to make it work is to install Robotium Recorder for Android Studio. After you record a test you can see how Robotium Recorder sets up the gradle files etc.
http://robotium.com/pages/installation-android-studio
Upvotes: 1