android-espresso

Generate coverage for other modules

痴心易碎 提交于 2019-12-23 13:06:40
问题 My project structure is as follows: :app , :core . :app is the Android application project, and it depends on :core which has all the business logic. I have Espresso tests for :app , and I am able to run and get coverage report thanks to all the questions and guides out there. But the coverage is only for code in :app . How do I get coverage for all projects ( :app and :core ) resulting from my Espresso instrumentation tests? Is this even possible? Any help is greatly appreciated. 回答1: Even

Properly cleanup / teardown after instrumentation test only when app is 100% finished

余生颓废 提交于 2019-12-23 12:55:13
问题 I have a bunch of end-to-end instrumentation tests (relying on Espresso) that start our launcher activity, then navigate throughout our app (eventually creating several activities). At the end of each test our @After annotated tear down method performs some cleanup. The problem we have is that after the test finishes (successful or failed assertion) the app is still "running", so some of the cleanup is actually causing the app to crash. This is either resulting in false positives if the

How to verify IntentService start

隐身守侯 提交于 2019-12-23 09:26:38
问题 I'm trying to test my app behavior with Espresso-2.2 On main activity, when button pressed both service and another activity is being started: public class MainActivity extends Activity { public void onButtonClicked() { startActivity(SecondActivity.getStartIntent()); startService(MyIntentService.getStartIntent()); } } I'm testing if intended components are being started: public class MainActivityTest { @Rule public final IntentsTestRule<MainActivity> intentsRule = new IntentsTestRule<>

Verify items in a popup menu with espresso

感情迁移 提交于 2019-12-23 09:22:51
问题 I have a popupmenu. Uix screenshot provided. Now I want to verify some items in the list by clicking them and verify what's happening. But no matter what I do I don't seem to be able to select items in the popup menu. The menu does not have an id and I don't think it's possible to set an id of a menu. I've tried different things like: onView(nthChildOf(anyOf(withId(android.R.id.title)), 1)).perform(click()); onView(withText("5 sekunder")).perform(click()); But nothing works. How do I click on

Android reports “Error=Unable to find instrumentation info for: ComponentInfo {}”

对着背影说爱祢 提交于 2019-12-23 09:05:23
问题 There are a lot of topics/questions regard this issue on stackoverflow (such as Error=Unable to find instrumentation info for: ComponentInfo{ }) and other website but the thing that make my problem different than others is I am working on automation. So let me give you more details. I have no problem when I'm testing on local machine (I mean my laptop). I can run Espresso testing and all tests passes. Now, I want to run these tests on CI (Bitrise in my case). I create and run Emulator. I

Espresso - typeText() not working correclty, sometimes letters are missing

旧街凉风 提交于 2019-12-23 08:02:25
问题 I start my login activity and I use in Espresso test: onView(withId(R.id.username)).perform(typeText("USERNAME")); I expect the text in the field to be "USERNAME", but sometimes I get "SERNAME", others "UERNAME". Most of the times it works but sometimes it fails, specially after rebooting the phone. Here is the sample code to reproduce the bug: https://github.com/neoranga55/CleanGUITestArchitecture 回答1: The test phone uses Swift keyboard with double language typing enabled. Apparently this

Google Espresso java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN

醉酒当歌 提交于 2019-12-23 07:59:30
问题 I am new to Espresso UI testing. I am getting this error while running tests (ADT Eclipse IDE ). The app is already developed and there are lots of request going on while launching the app. it is not possible to rewrite the app. but i need to find the way to test this UI even if there is any delay in the loading of the components. java.lang.RuntimeException: Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=com.xx.android/com.yy.core.android.map.MapActivity }

Android Espresso error on button click

﹥>﹥吖頭↗ 提交于 2019-12-23 07:47:30
问题 I'm trying to write some UI tests for an Android APP with the espresso framework. For now I'm just checking if all the elements are present on the splash screen and then I'm trying to click the login button. When the the button is clicked the test fails due to an error that I can't seem to understand why it's happening. My test code is @RunWith(AndroidJUnit4.class) @SmallTest public class WelcomeTest { @Rule public ActivityTestRule<Welcome> mActivityRule = new ActivityTestRule<>( Welcome

Android Architecture Component ViewModel - How to mock ViewModel on test Activity?

删除回忆录丶 提交于 2019-12-23 07:42:26
问题 I'm trying to setup UI testing similar to GithubBrowserSample and it looks like the sample project only has mock ViewModel for Fragment but not an example for Activity . Here's my code where I am trying to test the Activity by mocking ViewModel . But the ViewModel is not getting set before onCreate() in Activity. @RunWith(AndroidJUnit4::class) class MainActivityTest { val viewModel = mock(MainViewModel::class.java) @Rule @JvmField val activityRule = ActivityTestRule<MainActivity>(MainActivity

Testing RxJava2 using Espresso and getting a null pointer exception when suscribeOn

☆樱花仙子☆ 提交于 2019-12-23 07:26:02
问题 Android Studio 3.0 Beta2 I am testing getting a list for an endpoint using RxJava2. The app works fine when running normally. However, when I test using espresso I get a null pointer exception when I try and subscribeOn(scheduler) . For the schedulers I use the trampoline() for both subscribeOn and observeOn which are injected. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'io.reactivex.Observable io.reactivex.Observable.subscribeOn(io.reactivex.Scheduler)' on a