在机器人测试中,是否可以设置点击之间的等待时间?例如,我有2个按钮(A和B).我希望robotium点击按钮A然后20秒后点击按钮B.
我正在尝试使用命令行运行android instrumentation Junit测试.我正在使用以下命令,它正在启动测试权限.
adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)
我的android项目包有以下java源文件(按字母顺序)
com.android.foo
ActivityTest
ContactsTest
LaunchTest
SendTest
当我使用上面提到的命令运行测试时,测试首先开始执行ActivityTest,依此类推.这不是我想要的,我希望它首先执行LaunchTest,然后是ContactTest,SendTest和ActivityTest.我试过用
adb shell am instrument -w -e class com.android.foo.LaunchTest,com.android.foo.ContactTest com.android.foo/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)
但它给我一个错误可能是因为我没有在我的代码中使用TestCase类,而是我的LaunchTest和其他人扩展了ActivityInstrumentationTestCase2.
任何帮助表示赞赏.
我想为Android应用程序编写Robotium/Junit测试.在某些步骤中,我希望我的测试等到旋转加载符号从屏幕上消失.
我怎样才能做到这一点?
我有一个应用程序,在呼叫结束后立即启动活动.我想写一个自动测试,确保:
我看了一下Robotium和Roboelectric框架,但是如果它完全可行的话就无法找到答案.
我正在完成移动到操作栏(使用actionbarsherlock),最后一件事就是转换所有的机器人集成测试.单击操作栏操作项似乎已解决,但我无法弄清楚如何使用Robotium单击操作栏选项卡.
我在我的应用程序中自动测试流程,我在那里安装了设备管理员.要激活大多数设备上的设备管理员(我们假设我没有一些企业API可以让我像三星提供的那样),系统会向用户显示弹出窗口,然后用户必须单击"激活"按钮.
我正在使用Robotium和Android JUnit来推动我的测试.在正常的测试案例中,人们只能与被测试的应用程序和流程进行交互,而不能与出现的任何系统活动进行交互.
该UiAutomation声称让你与利用其他应用程序进行交互访问性框架,然后让一个注入任意输入事件.
所以 - 这就是我要做的事情:
public class AbcTests extends ActivityInstrumentationTestCase2<AbcActivity> {
private Solo mSolo
@Override
public void setUp() {
mSolo = new Solo(getInstrumentation(), getActivity());
}
...
public void testAbc(){
final UiAutomation automation = getInstrumentation().getUiAutomation();
MotionEvent motionDown = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), KeyEvent.ACTION_DOWN,
100, 100, 0);
// This line was added in to give a complete solution
motionDown.setSource(InputDevice.SOURCE_TOUCHSCREEN);
automation.injectInputEvent(motionDown, true)
MotionEvent motionUp = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), KeyEvent.ACTION_UP,
100, 100, 0);
// This line was …
Run Code Online (Sandbox Code Playgroud) 在我的Android应用程序中,我启用了多索引.该应用程序在模拟器上运行良好.我正在使用robotium来测试应用程序.但是当我执行检测测试用例时,有时测试会通过,但大多数情况下它们在系统重启后也会失败.通过和失败之间没有代码更改.
默认gradle配置:
android {
defaultConfig {
applicationId "com.example.androidapp"
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled true
testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
testProguardFile "proguard-test.txt"
}
}
Run Code Online (Sandbox Code Playgroud)
还要为测试添加依赖项:
androidTestCompile fileTree(dir: 'libs', include:'robotium-solo-5.3.0.jar')
androidTestCompile ('com.android.support:multidex-instrumentation:1.0.1') {
exclude group: 'com.android.support', module: 'multidex' }
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest.xml中,我提到了应用程序标记:
<application
android:name="StartupActivity"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" ...../>
Run Code Online (Sandbox Code Playgroud)
我在StartupActivity中扩展了"android.support.multidex.MultiDexApplication".仪器测试用例下降的时间我得到以下错误:
INSTRUMENTATION_RESULT: shortMsg=java.lang.IllegalAccessError
INSTRUMENTATION_RESULT: longMsg=java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
INSTRUMENTATION_CODE: 0
Run Code Online (Sandbox Code Playgroud)
logcat中的错误消息是:
W/dalvikvm? Class resolved by unexpected DEX: Lcom/example/androidapp/StartupActivity;(0xa695df08):0x9910e000 ref [Landroid/support/multidex/MultiDexApplication;] Landroid/support/multidex/MultiDexApplication;(0xa695df08):0x99a2c000
W/dalvikvm? (Lcom/example/androidapp/StartupActivity; had used a different Landroid/support/multidex/MultiDexApplication; during pre-verification)
W/dalvikvm? Unable to …
Run Code Online (Sandbox Code Playgroud) android gradle robotium android-instrumentation android-multidex
Robotium中的Solo类上的waitForCondition()使用Sleeper对象在检查条件之间休眠线程.Sleeper类的PAUSE定义为500毫秒.我想降低它,理想情况下不需要下载Robotium源代码,更改它,并重新编译Robotium.
我尝试扩展Solo类并构建我自己的Waiter类,该类将使用具有较低睡眠间隔的自定义Sleeper对象,但Waiter具有包级访问权限,因此此路由不可用.
除了最后的关键字,这个提交消息似乎表明自定义配置应该(或即将到来),但我没有看到任何方法在Solo.Config类中自定义这些常量.
有没有人有任何解决方案?谢谢!
更新: @ vRallev在下面的答案通过反射完成工作.我做了一个拉动请求,今天合并到了Robotium.在下一个版本中,您将能够使用Config类配置休眠时间.