FAQ Database Discussion Community

android espresso testing : empty test suite. no tests were found

I am running intelliJ idea 14.0.2 android development environment on windows and am trying to use the espresso UI testing framework to test my app.However when I press run for an androidTest configuration , I encounters the following : Testing started at 12:09 PM ... Waiting for device. Target device:...

Android Studio Espresso Testing Error: Empty Test Suite

I keep running into the following error when trying to execute my tests in Android Studio: Test running failed: Unable to find instrumentation info for: ComponentInfo{.test/android.support.test.runner.AndroidJUnitRunner} My test class is in the androidTest/java directory and has a constructor. My build.gradle is correct too. Any help is appreciated. Test Class @RunWith(AndroidJUnit4.class)...

Using Espresso to Unit Test Google Maps

I am using Espresso for unit testing my app. I have a fragment with a map, and I display some items on it that I get through a call to my backend. When I click on a marker, I'm doing some UI things Is there any way I can do...

Find footer and test using Espresso

I have a custom adapter like MyCustomAdapter which extends BaseAdapter. I also have a listView which I add a footerView to it: protected ListView mItemsList; // Adapter protected myCustomAdapter mAdapter; @VisibleForTesting public static final String FOOTER = "FOOTER"; View footerView = LayoutInflater.from(this).inflate(R.layout.footer_view, mItemsList, false); mItemsList.addFooterView(footerView, FOOTER, true); Now I want...

ActivityTestRule.getActivity returns null in Before method

I need to empty my user's data before each test // Kotlin code fun getActivity() = activityRule.getActivity() Before fun setUp() { cleanUp(getActivity()) } I need to get a Context in order to do so, but in setUp, activityRule.getActivity() returns null. I also tried: Before fun setUp() { val i =...

Espresso Android testing - using getActivity in a helper method (can't find method to import)

I'm testing an Android app with Espresso. I'm trying to write a helper function in a helper class that can check the value of a spinner with the following code: public static void assertSpinner(MainActivity activity, int id, int val) { Spinner s = (Spinner) activity.findViewById(id); assertNotNull(s); assertEquals(val, s.getSelectedItemPosition()); } I...

Espresso: how to click on StickyListHeadersListView item inside viewpager

I have ViewPager with N tabs with StickyListHeadersListView inside each of them. I'd like to perform click on one of the list item. How could I do that? thanks! PS: I'm interested in Espresso test code only...

What JARs are needed for Espresso testing?

I am starting to use Espresso for testing in an android app and I am having a problem setting up the JARs and was wondering if anyone could help me with the set up.

Proguard issue Roboguice duplicate import

I am running to an issue when i run my gradle build. It seems like there are duplicate dependencies getting imported but finding it hard to debug, any suggestions would be great. Error:Execution failed for task ':proguardDebug'. java.io.IOException: Can't write [.......\build\intermediates\classes-proguard\debug\classes.jar] (Can't read [.......gradle\caches\modules-2\files-2.1\org.roboguice\roboguice\3.0.1\24e814f35d5cc28eaa7e9f07a50ea69deeb2b544\roboguice-3.0.1.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry...

AndroidTest folder doesn't show on AndroidStudio

I'm setting up Android app structure with Gradle and Android Studio and Espresso UI testing for a project. No matter what I try, the androidTest folder never appears in AndroidStudio's project structure. Project (root) build.gradle: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.2' } } allprojects { repositories...

Simulate user click in system activities with Android Espresso framework

In my application I'm turning on BlueTooth when first Activity starts up. It results in the system dialog asking for the authorization to activate the BlueTooth. How can I asset that this dialog is present and click on the "Yes" Button with Espresso ? Is it possible ? I tried...

How to use Espresso Idling Resource for network calls

Im trying to use Espresso to test my UI. When i login into my application, i do a call to Parse API (network call) to verify the username and password. If all is well the user gets directed to a new activity. I want to test this, but i cant...

Espresso how to click on a ImageView placed in listview's first item?

I have a custom layout for listview, I want to click on a imageview placed in the list view item, overflow icon of the first item in the list view. I want to click on last imageview with id "rcOverflow" My layout, <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="left" android:paddingBottom="10dp" android:paddingTop="5dp"> <ImageView...

How can I perform a multi touch swipe with Espresso?

How can I perform a multi touch swipe with Espresso? e.g. a two finger swipe to the right.

How Can to test by Espresso android.widget.TextView setError?

I have password.setError(getResources().getString(R.string.incorrect_data)); If I set invalid password - show textView with text "Invalid data!", I need to test it by Espresso, I write: onView(withText(R.string.incorrect_data)).check(matches(isDisplayed())); But it is wrong, I have: android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with string from resource id: <2131493034>[incorrect_data] value: Invalid data! If the target...

Click on not fully visible imageButton with Espresso

I have a custom ImageButton that is not fully visible, by design, so when I perform a click action I get this error: android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: test.com.myproject.app:id/navigationButtonProfile'. Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or...

Assert proper number of items in list with espresso

What is the best way to inspect and assert that a listview is the expected size with android espresso? I wrote this matcher, but don't quite know how to integrate it into the test. public static Matcher<View> withListSize (final int size) { return new TypeSafeMatcher<View> () { @Override public boolean...

How to use Espresso Idling Resource

The scenario is when the user click on the "Download" button, the data (a music/an image etc.) starts being downloaded from the internet. When the download is finished, the button changes it label text to "Open". The user then click on that "Open" button. What I've done sofar is: onView(allOf(withId(R.id.button),withText("Download"))).check(matches(isClickable())).perform(click());...

Android Espresso: Test running failed. No test results Empty test suite. Why?

Can't make my Espresso UI test work. Where's the problem? What result should I get for this simple app to consider that it's working? I have "android.support.test.runner.AndroidJUnitRunner" for Instrumentation runner in Edit Confirurations. From AndroidManifest.xml: <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" android:targetPackage="my.package"/> From build.gradle: defaultConfig { applicationId "my.package" minSdkVersion 18 targetSdkVersion 22 versionCode 1...

How to disable animations in code when running Espresso tests

Has anybody managed to disable animations through code when running Espresso tests? I've been trying to follow the instructions in this webpage (linked to from here): https://code.google.com/p/android-test-kit/wiki/DisablingAnimations Unfortunately it does not appear to be working, as I keep seeing this permissions error: 04-27 15:48:28.694 303-342/system_process W/PackageManager﹕ Not granting permission android.permission.SET_ANIMATION_SCALE...

How to detect whether android app is running UI test with Espresso

I am writing some Espresso tests for Android. I am running in the the following problem: In order for a certain test case to run properly, I need to disable some features in the app. Therefore, in my app, I need to detect whether I am running Espresso test so...

Android Espresso how to write tests using apk?

I am a robotium user now switching to Espresso can anyone tell me how to write tests using apk in espresso, as we do in robotium without having acccess to the code but using app apk. And how to access views without R.id.viewid in espresso? as we do in robotium...

AndroidTestCompile dependencies not recognized in the imports

Actually, my project has unit tests. All of them are configured in /src/test/java/ and recently, I needed to add instrumental test in /src/androidTest/java. To do that I have added espresso dependencies in build.gradle. dependencies { compile files('libs/pixlui-1-0-5.jar') // You must install or update the Support Repository through the SDK manager...

Espresso 2.1 doesn't find my tests

I have looked through all the questions on stack I found with similar problem, but none has given me an answer that actually work (http://stackoverflow.com/search?q=espresso+empty+test+suite). I have a simple project I want to try espresso on. My class file looks like this: package com.example.myapplication; import android.app.Activity; import android.content.Intent; import android.os.Bundle;...

Android Espresso test on wrong activity

I have two activities on my app: a login activity (loginActivity) and a second activity (mainActivity). I want to use Espresso to test the login on the loginActivity, so I wrote this test: public class LoginActivityTest extends ActivityInstrumentationTestCase2<LoginActivity> { public LoginActivityTest() { super(LoginActivity.class); } @Override public void setUp() throws Exception...

Espresso: how to scroll to the bottom of ScrollView

How is it possible to scroll down to the bottom of ScrollView in Espresso test? Thanks!

NPE @ android.support.v7.widget.RecyclerView$LayoutManager.detachViewInternal

when switching from espresso 2.0 to 2.1 i am stumbling uppon this strange error: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.ChildHelper.detachViewFromParent(int)' on a null object reference at android.support.v7.widget.RecyclerView$LayoutManager.detachViewInternal(RecyclerView.java:5407) at android.support.v7.widget.RecyclerView$LayoutManager.detachViewAt(RecyclerView.java:5400) at android.support.v7.widget.RecyclerView.setAdapterInternal(RecyclerView.java:647) at...

Wait for callback without blocking main thread

I am stuck and will be glad to get any help! I am writing tests for an android library. The task is to make some actions in an activity and check that library responds correctly. My problem is that my test finishes just after all actions in activity are done...

How can to test in Espresso without R.id.edit_text?

I create dynamic fields in my class. And I cannot to write EditTexts in layout (.xml), so I have not R.id.edit_text, How Can to test edit text without R.id.edit_text in Espresso 2? If I have R.id.edit_text - I can write onView(withId(R.id.edit_text)).perform(typeText("123")); But I have not the R.id.edit_text.

Espresso 'is enabled' doesn't match the selected view

I'm using Espresso 2 to test that a button is enabled or not. My code looks like this: onView(withId(R.id.fragment_vote_pause_btn)).check(matches(isEnabled())); My button is defined as: <Button android:id="@+id/fragment_vote_pause_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@android:color/transparent" android:text="@string/audiowave_pause_or_play"...

isIdleNow() is returning true, but a message indicating that the resource has transitioned from busy to idle was never sent

I try to write some test in espresso for my android application, and I have a problem with Idle. If my isIdleNow() looks like this public boolean isIdleNow() { return true; } message is sent. But if IsIdleNow() must wait for some conditions (it doesn't return true at start) message...

Checking toast message in android espresso

Would anyone know how to test for the appearance of a Toast message in android espresso? In robotium its easy & I used but started working in espresso but dont getting the exact command. Thanks in advance

Espresso android — Evoke assert? (NOT a view assert)

I'm looking to do a simple test. I just want my espresso test script to verify that I'm not on production. Bad things happen if I run a purchase on production, let alone lots them.. I know in Java you need to add a -ae to run assertions. Which doesn't...

Espresso test is passed only first time. Then is failed constantly because of NoMatchingViewException

I work in Android Studio. I'm currently working on automation tests creation using Espresso 2.1: androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1' I have following xml layout for MainActivity class: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <com.esri.android.map.MapView android:id="@+id/mapView"...

How do you click a menuItem in NavigationView on Android when testing with Espresso?

How do you click on a menuItem in a NavigationView from the design library using Espresso? It works fine on a larger devices where the whole menu is visible but in landscape or smaller devices the bottom of my menu is off the screen and I can not figure out...

Is there any way to know if an activity has been started with Espresso?

I'm doing an Activity transition testing with Espresso but I don't know if this is the best way to do it: public void testStartLogin() { onView(withId(R.id.register)).perform(click()); onView(withId(R.id.login_password)).check(matches(isDisplayed())); onView(withId(R.id.login_show_password)).check(matches(isDisplayed())); } The last two are from the second activity but this looks horrible for me. Is there any different way?...

Android Testing Support Library not found with Espresso and different BuildVariants

We have three BuildVariants: release, debug and develop. The first are the defaults from AndroidStudio. The last is for our internal testing. Here are the configs: (There is nothing different than Signing Config) We have imports the following in our build.gradle: dependencies { // App dependencies compile 'com.android.support:support-annotations:22.0.0' compile 'com.google.guava:guava:18.0'...

Android tests build error: Multiple dex files define Landroid/support/test/BuildConfig

I'm trying to add Espresso 2 to my project (which also has lots of other dependencies), but I'm hitting this error when trying to run tests: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/test/BuildConfig; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) ... The non-test build works fine. Does anybody have...

ActivityTestRule - how to call code before Application's onCreate

I am using Espresso 2.1 with ActivityTestRule, and I am looking for a way to set some static flags before onCreate() in my application will be called. I have some init code that I don't want called during instrumentation tests....

Espresso how to wait for some time(1 hour)?

In my test case I have to record for 1 hour, in robotium solo.sleep(600000) had done my work, but In espresso I am confused with IdlingResource concept. I have to start recording and wait for some time(depending on the type of test) 15mins, 60mins etc. Equivalent code in robotium solo.clickOnView(solo.getView("start_record"));...

Testing ViewPager with Espresso. How perfom action to a button of an Item?

I have a ViewPager whith items containing only a picture and a button. I can't success to interact with the UI of an item (Page) because, excepted the displayed picture, there is nothing to differentiate (from UI point of view) all items of the ViewPager. I tried to select only...

Espresso How to access views without using R.id.viewid as we do in robotium?

I am switching from robotium to espresso, I am writing tests using apk, I dont have access to code. In robotium using solo.getView("view-id") we can access the view but I am not geting how to do it in espresso? espresso witId() method needs R.id.viewid which I dont have access. public...