有谁知道如何在android浓缩咖啡中测试Toast消息的外观?在机器人中它很容易和我使用,但开始在浓缩咖啡工作,但没有得到确切的命令.
该应用程序在本地传递espresso测试,我的意思是直接到设备和genymotion模拟器.当我使用Jenkins构建应用程序的图像时.espresso测试不成功我收到此错误.
JENKINS:
java.lang.RuntimeException: Waited for the root of the view hierarchy to have window focus and not be requesting layout for over 10 seconds. If you specified a non default root matcher, it may be picking a root that never takes focus. Otherwise, something is seriously wrong. Selected Root:
Root{application-window-token=android.view.ViewRootImpl$W@536a97d4, window-token=android.view.ViewRootImpl$W@536a97d4, has-window-focus=false, layout-params-type=1, layout-params-string=WM.LayoutParams{(0,0)(fillxfill) sim=#100 ty=1 fl=#1810100 pfl=0x8 wanim=0x103028f}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=800, height=1184, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}}
. All Roots: …Run Code Online (Sandbox Code Playgroud) 我正在开发我的第一个Android应用程序,我正在设置CI服务器.我的espresso咖啡测试在我的机器上正常运行,但travis错误出现以下情况
java.lang.RuntimeException:等待视图层次结构的根目录具有窗口焦点,而不是请求布局超过10秒.
在运行测试之前,我似乎需要解锁仿真器屏幕.为此,我必须src/debug使用所需权限添加清单,然后使用以下命令解锁屏幕:
KeyguardManager mKeyGuardManager = (KeyguardManager) ctx.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock mLock = mKeyGuardManager.newKeyguardLock(name);
mLock.disableKeyguard();
Run Code Online (Sandbox Code Playgroud)
问题是我不想乱丢我的活动,上面的代码包含在if块中.有没有办法从浓缩咖啡测试中解锁屏幕?
我的浓咖啡测试:
@RunWith(AndroidJUnit4.class)
public class EspressoSetupTest {
@Rule
public final ActivityTestRule<WelcomeActivity> activity =
new ActivityTestRule<>(WelcomeActivity.class, true, true);
@Test
public void launchTest() {
onView(withId(R.id.welcome_textView_hello))
.perform(click())
.check(matches(withText("RetroLambda is working")));
}
}
Run Code Online (Sandbox Code Playgroud)