android-testing

Controlling when an automation test ends - Espresso

元气小坏坏 提交于 2020-01-02 09:56:33
问题 I have an unusual situation I am testing. I am using Espresso to write my tests. I know Espresso and InstrumentationTestCase is not meant to do this. I have a Listener I created in one of my classes that will notify me of a change of a certain value. I use the listener in my test suite. When I get the value from the listener, I need to assert the value was changed as such. My problem is the test will end before I will receive the value form the listener. private void sendSpeedChanges() {

Robolectric, Problems with clicking list items

隐身守侯 提交于 2020-01-02 01:55:15
问题 I have been struggling with this problem a bit, and I think I am not getting something fundamental about Robolectric. Usually some google searches can help me get to the bottom of this type of problem, but between that and looking at the sample code I am not finding anything of use. I am trying to emulate a click on a list view item and check that an activity is launched after the click. I keep getting back that the current activity I am testing is the resulting activity. I tried removing all

Android Base64 encode and decode return null in Unit Test

无人久伴 提交于 2020-01-02 00:27:13
问题 I am attempting to decode a Base64 encoded string in Android using the http://developer.android.com/reference/android/util/Base64.html class. Both the encodeToString and decode methods are returning null, and I have no idea what's wrong, here's my code for the decode: // Should decode to "GRC" String friendlyNameBase64Encoded = "R1JD"; // This returns null byte[] friendlyNameByteArray = Base64.decode(friendlyNameBase64Encoded, Base64.DEFAULT); // Fails with NullPointerException String

Adding layout resources to androidTest

我们两清 提交于 2020-01-01 08:22:47
问题 I would like to add layout xml files into my androidTest folder to be used only for testing. I added res/layout folder to androidTest and tried to add a layout file to it. But it gives error URI is not registered for xmlns:android="http://schemas.android.com/apk/res/android" Somehow the project does not recognize it as valid layout file. 回答1: It is tricky to add xml resources to androidTest . Android Instrumentation tests create another APK to run the tests against your original application.

Adding layout resources to androidTest

半城伤御伤魂 提交于 2020-01-01 08:20:00
问题 I would like to add layout xml files into my androidTest folder to be used only for testing. I added res/layout folder to androidTest and tried to add a layout file to it. But it gives error URI is not registered for xmlns:android="http://schemas.android.com/apk/res/android" Somehow the project does not recognize it as valid layout file. 回答1: It is tricky to add xml resources to androidTest . Android Instrumentation tests create another APK to run the tests against your original application.

Testing Notifications in Android

女生的网名这么多〃 提交于 2020-01-01 05:20:14
问题 My android app has a service which sends notifications to user based on parameters like number of runs of the app. The notifications are sent at different times in different situations. I want to test whether notifications are sent at the right times in all the different cases. Does android provide a way of such a testing ? 回答1: Testing Notification using UIAutomator: Just go through the below code. It will help you in testing the notification. UiDevice device = UiDevice.getInstance

When i run my android UIAutomator code, it shows error

两盒软妹~` 提交于 2020-01-01 04:17:34
问题 When I run my android UIAutomator code, it shows following error. INSTRUMENTATION_RESULT: shortMsg=java.lang.RuntimeException INSTRUMENTATION_RESULT: longMsg=com.android.ui.testing INSTRUMENTATION_CODE: 0 I just ran the sample code given in developer.android.com How to solve this error? Log attached below: 01-05 01:07:53.559: D/AndroidRuntime(5712): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 01-05 01:07:53.559: D/AndroidRuntime(5712): CheckJNI is ON 01-05 01:07:53

How to force Android application to use either 32bit or 64 bit libraries

别说谁变了你拦得住时间么 提交于 2019-12-31 10:01:32
问题 On a Android device with 64bit ARM, would have two variants of many libraries, 32bit and 64 bit, and their performance could be different. I want to know if there is a way to force the application to use either 32bit or 64bit libraries. 回答1: ABI can be specified when the apk is installed. adb install --abi <path to apk> In case ARM device, To run in 32 bit mode install using, adb install --abi armeabi-v7a <path to apk> To run in 64 bit mode install using, adb install --abi arm64-v8a <path to

SimpleTestCursor robolectric 3.0— compilation issue

瘦欲@ 提交于 2019-12-31 04:30:10
问题 I am trying to test the cursor in my app. But for the following import I get the error message-- cannot resolve symbol tester. I am using Robolectric 3.0. Why the import is not resolving, am I missing some dependency? I have looked internet but no support. Please help. I am trying to use:this API and following is the import import org.robolectric.tester.android.database.SimpleTestCursor; These are my dependencies: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile

Espresso NestedScrollView

為{幸葍}努か 提交于 2019-12-30 08:15:10
问题 I am trying to test EditTexts in my form that are within a NestedScrollView. I am running the following code: onView(withId(R.id.register_scroll_view)).perform(scrollTo()).perform(click()); where register_scroll_view is my NestedScrollView. However, I am getting an exception: android.support.test.espresso.PerformException: Error performing 'scroll to' on view 'with id: com.eazyigz.myapp:id/register_scroll_view'. Caused by: java.lang.RuntimeException: Action will not be performed because the