小编Com*_*ter的帖子

应用程序选择器 - Android Espresso单元在打开外部URL后测试中断

我有一个带有登录屏幕的Android应用程序,其中还包含一个忘记密码按钮,可以将您带到网站以获得进一步的帮助.我正在使用Spoon和Espresso进行测试,具有以下简单的测试功能:

@Test
public void testForgotPassword()
{
    onView(withId(R.id.login_forgot_password)).perform(click());

    intended(allOf(
            hasAction(Intent.ACTION_VIEW),
            hasData(BuildConfig.FORGOT_PW_URL)));
}
Run Code Online (Sandbox Code Playgroud)

此测试通过正常,并在屏幕上显示"使用浏览器/ chrome对话框完成操作",这是此设备的正确行为.到目前为止都很好.但是,只要该对话框保留在那里,任何后续测试都无法打开应用程序,在长时间停顿并且测试失败后返回异常.

如何更新测试以主动摆脱对话框,或者确保我可以继续进行剩余的单元测试?

完整的例外情况供您参考:

2016-04-21 17:37:04 [STRL.testFailed] failed java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=nl.test.example/.ui.activity.login.LoginActivity_ } within 45 seconds. Perhaps the main thread has not gone idle within a reasonable amount of time? There could be an animation or something constantly repainting the screen. Or the activity is doing network calls on creation? See the threaddump logs. For your reference the last time the event queue …
Run Code Online (Sandbox Code Playgroud)

android unit-testing spoon android-espresso

3
推荐指数
1
解决办法
1219
查看次数

在 gradle 任务中获取 Android SDK 目录

最近android的gradle插件更新了(用android studio),之后之前进入sdk目录的方式就失效了。表达方式

${android.plugin.sdkDirectory}
Run Code Online (Sandbox Code Playgroud)

在旧版本中工作的现在返回错误

Error:(42, 0) No such property: sdkDirectory for class: com.android.build.gradle.LibraryPlugin
Run Code Online (Sandbox Code Playgroud)

获取正在使用的 android SDK 目录的正确方法是什么,最好独立于用户的配置,例如插件和 gradle 版本?该脚本需要可与多个用户共享。

android android-gradle-plugin

2
推荐指数
1
解决办法
3320
查看次数