有谁知道如何在android浓缩咖啡中测试Toast消息的外观?在机器人中它很容易和我使用,但开始在浓缩咖啡工作,但没有得到确切的命令.
我正在为Android编写一些Espresso测试.我正在运行以下问题:
为了使某个测试用例正常运行,我需要在应用程序中禁用某些功能.因此,在我的应用程序中,我需要检测我是否正在运行Espresso测试,以便我可以禁用它.但是,我不想使用BuildConfig.DEBUG,因为我不希望在调试版本中禁用这些功能.此外,我想避免创建一个新的buildConfig,以避免创建太多的构建变体(我们已经定义了很多风格).
我一直在寻找一种方法来定义buildConfigField以进行测试,但我在Google上找不到任何引用.
我关闭了开发者选项的所有动画.但是当我尝试点击其中一个按钮时,我仍然会遇到此异常.
我的应用确实是活跃的,并没有完全闲置,但我无法改变它.
android.support.test.espresso.AppNotIdleException: Looped for 6930
iterations over 60 SECONDS. The following Idle Conditions failed .
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:580)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:92)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:56)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
Run Code Online (Sandbox Code Playgroud) 工作流程应如下:
到目前为止,我已经为第1,3,5步编写了断言,它完美地运行:
onView(withText("foo 1"))
.check(matches(isDisplayed()));
Run Code Online (Sandbox Code Playgroud)
问题是,我不知道如何让espresso知道在请求发出之前和发出请求之后验证进度条的可见性.
考虑onCreate()方法如下:
super.onCreate(...);
setContentView(...);
showProgressBar(true);
apiClient.getStuff(new Callback() {
public void onSuccess() {
showProgressBar(false);
}
});
Run Code Online (Sandbox Code Playgroud)
我尝试了以下但它不起作用:
// Activity is launched at this point.
activityRule.launchActivity(new Intent());
// Up to this point, the request has been fired and response was
// returned, so the progress bar is now GONE.
onView(withId(R.id.progress_bar))
.check(matches(isDisplayed()));
onView(withId(R.id.progress_bar))
.check(matches(not(isDisplayed())));
Run Code Online (Sandbox Code Playgroud)
发生这种情况的原因是,由于客户端被注册为空闲资源,espresso将在运行第一个之前等待它再次空闲,onView(...progressbar...)...因此我需要一种方法让espresso知道在进入空闲状态之前运行.
编辑:这也不起作用: …