[英]enabling Robotium in Android
I recently decided to switch from Eclipse to Android Studio. 我最近决定从Eclipse切换到Android Studio。 While i was able to import my android project, i keep having problems setting up and transfering my unit tests.
虽然我能够导入我的Android项目,但我一直在设置和转移我的单元测试时遇到问题。 For testing purposes i made a directory in src folder (java folder and test package).
出于测试目的,我在src文件夹(java文件夹和测试包)中创建了一个目录。 For enabling robotium i followed another stack topic by adding
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
. 为了启用robotium,我通过添加
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
跟随另一个堆栈主题。 Eventually i added my test java file from Eclipse. 最后我从Eclipse添加了我的测试java文件。 And when i try to run tests, i keep getting "Cannot resolve symbol Solo".
当我尝试运行测试时,我不断得到“无法解决符号Solo”。
I have little understanding about how AS and gradle works, so probably i am missing something else. 我对AS和gradle如何工作几乎一无所知,所以可能我错过了其他的东西。 The contents of my build.gradle file:
我的build.gradle文件的内容:
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.+'
}
I think the easiest way to make it work is to install Robotium Recorder for Android Studio. 我认为最简单的方法是为Android Studio安装Robotium Recorder。 After you record a test you can see how Robotium Recorder sets up the gradle files etc.
录制测试后,您可以看到Robotium Recorder如何设置gradle文件等。
http://robotium.com/pages/installation-android-studio http://robotium.com/pages/installation-android-studio
You must use separate source set for you android-specific tests, ie: 您必须为特定于Android的测试使用单独的源集,即:
sourceSets {
main {
java.srcDirs = ['src/main/java']
}
androidTest {
java.srcDirs = ['src/tests/java']
}
}
使用androidTestCompile'com.jayway.android.robotium:robotium-solo:5.5.4'解决所有测试用例问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.