我现在正在进行我的功能测试,在其中一个测试中,我必须测试未显示toast消息。考虑到这是我用来检查是否显示toast消息的代码(此代码有效):onView(withText(R.string.my_toast_message)).inRoot(withDecorView(not(getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));您可以在下面找到我用来检查是否未显示toast消息的代码(它们都不起作用):方法一:onView(withText(R.string.error_invalid_l
我想将数据放入androidTest/res/values/string.xml文件夹的xml文件中。我已经创建了包含以下内容的文件test.xml。hello当我尝试通过R.string.test访问现场测试时。它不可访问并显示“无法解析符号测试”。有人可以在这里给我建议吗。 最佳答案 这是你的做法:importcom.my.example.test.R;Resourcesresources=InstrumentationRegistry.getContext().getResources();Stringterms=resour
我开始使用espresso并编写了一些简单的UI测试,用于点击按钮、输入文本并检查是否一切都在应有的位置。现在我想截屏并测试一些像素值,但我找不到办法做到这一点。有人有什么建议吗?Espresso甚至可能吗? 最佳答案 由于Espresso测试是简单的InstrumentationTestCases,您可以使用paparazzoandcelebrity截取您的应用程序的屏幕截图。Spoon也是一个非常好的屏幕截图系统。比狗仔队更清晰,但只能截取Activity的屏幕截图,不能截取对话。最后但同样重要的是,自androidSDK16起
我实际上尝试用Espresso设置一些单元测试,经过几个小时的研究,该应用程序只执行单击并通过EditText获得焦点,但之后什么都没有Causedby:android.support.test.espresso.AppNotIdleException:Loopedfor1996iterationsover60SECONDS.ThefollowingIdleConditionsfailed.我删除了所有动画和SwipeRefreshLayout,因为我看到swiperefresh有一个错误我实际上使用了一些回调来替换Activity中的当前fragment如果有人有一些提示,我会在搜索
我正在尝试测试使用ViewPager的应用程序。每个页面都包含fragment,但这些fragment并不总是可见的。我想检查当前可见页面中fragment的可见性。onView(withId(R.id.container_weather)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));但问题是espresso看起来是所有页面,而不仅仅是当前页面,我收到以下错误:android.support.test.espresso.AmbiguousViewMatcherException:'w
在我的应用程序中,当用户单击“注册”按钮时,将启动RegisterActivity。用户填写表单后,详细信息将发布到Web服务,如果注册成功,RegisterActivity将以RESULT_OK结束。下面的代码示例总结了这一点:publicvoidsubmitRegistration(){showProgressDialog(R.string.registration,R.string.please_wait);getWebApi().register(buildRegistrationFromUI(),newCallback(){@Overridepublicvoidsuccess
我是android测试的新手。如果用户单击按钮并且TextView为空,我试图让测试失败。有没有办法在Espresso中执行此操作,因此如果TextView为空,它将失败。我不想检查TextView是否包含特定文本,我想检查它是否不为空。 最佳答案 试试这个:importstaticandroid.support.test.espresso.Espresso.onView;importstaticandroid.support.test.espresso.action.ViewActions.click;importstatican
我想测试当我收到推送时,通知会出现。也可以检查其属性(如标题、设置Intent等。)我该怎么做?@BeforepublicvoidsetupTest(){mData.putString(PushNotificator.KEY_PUSH_TYPE,PushType.PROJECT_OFFER.toString());mData.putString(PushNotificator.KEY_PUSH_OBJECT,pushObjectJsonString);mContext=InstrumentationRegistry.getContext();}@Testpublicvoidprojec
这似乎是正确的...onView(withId(R.id.menu_delete)).check(matches(not(isDisplayed())));...但是它抛出这个异常:android.support.test.espresso.NoMatchingViewException:Noviewsinhierarchyfoundmatching:withid:com.just10.android:id/menu_deleteIfthetargetviewisnotpartoftheviewhierarchy,youmayneedtouseEspresso.onDatatoload
我正在尝试编写一个简单的测试,我只需单击主Activity中的MenuItem:publicclassdoTestextendsActivityInstrumentationTestCase2{publicdoTest(){super(doActivity.class);}@OverridepublicvoidsetUp()throwsException{super.setUp();startActivity();}privatevoidstartActivity(){Intentintent=newIntent();setActivityIntent(intent);getActiv