Questions tagged [android-testing]

1

votes
3

answer
797

Views

Failed to finalize session : INSTALL_FAILED_INVALID_APK: /data/app/…tmp/…-debug version code 29 inconsistent with 28

This error happens when i try to run the app on the simulator: It asks if it can uninstall the current application but there is no application installed on the simulator. If i click ok, just fails. I try to invalidate cache and restart, to reboot the pc, to create a new simulator, to update Android...
ByteArtisan
1

votes
1

answer
12

Views

How can test MutableLiveData<>.observe when the data is changed?

I have the next code for test if the API is working with Login function: @RunWith(RobolectricTestRunner.class) public class LoginTest { LoginRespository profileRepository = new LoginRespository(RuntimeEnvironment.application); @Test public void testLogin() { MutableLiveData data = new MutableLiveDat...
Tlaloc-ES
1

votes
1

answer
328

Views

Android Robo test cannot find element

I want to use Robo test from google firebase for my application. My application needs login process. I want to use resource and value mapping system. I filled in the form like this However, test report says that there are no such resource names Resource name was copied from android UI Automator Vie...
John
1

votes
1

answer
51

Views

Automated mobile testing strategy for the usecases that involves multiple phones - say bluetooth data transfer, etc

What could be the best automation test strategy for mobile uses cases that involve multiple devices: Bluetooth data transfer Push data from one phone and pull the same from other phone Hit like or share button on one phone and see the count updated on the other phone Send SMS from one phone and chec...
RaMo
1

votes
0

answer
97

Views

Test execution using gradle connectedAndroidTest does not execute parallely on all connected devices

I am performing instrumented test execution using gradlew connectedAndroidTest on physical devices. But while doing this, I observe that irrespective of number of devices connected to my machine, at max 3-4 devices only have the tests running. For Example - If I have 10 android devices connected to...
Shredder
1

votes
1

answer
74

Views

Tests never get executed because of the Mockito.doThrow

I am testing an anroid app using Mockito. I want to test an exception case, but the method Mockito.doThrow hangs and the test never gets executed (it neither fails nor succeeds). Here's the code. PackageDownloader represents an AsyncTask. Its method get gets called inside of the downloadPackage meth...
annaoomph
1

votes
1

answer
430

Views

How to prevent from Android monkey to turn off WIFI?

Sometimes, WIFI is turned off with following command to run monkey test on Android. Is there any method to prevent the Android monkey to turn off WIFI? adb -s foo shell monkey -p com.foo.bar --throttle 300 --kill-process-after-error --pct-syskeys 0 --pct-trackball 0 --pct-touch 90 --pct-motion 10 -v...
sdet_liang
1

votes
3

answer
274

Views

Descriptions for ViewAssertion in Espresso

I have this code: onView(withId(R.id.my_view)).check(matches(isDisplayed())) How can I add my own message to it in case of a fall of the test with an error? For example as in junit: assertEquals('My message', expected, actual)
Hamster
1

votes
1

answer
261

Views

Espresso Assertion Failed With Cause Error

I have been trying to run a test on espresso, which will give input to editText and will hit a button and then it goes for validation, I have included dependencies tried clearing cache but still facing this error Here is the test @RunWith(AndroidJUnit4.class) public class Espresso { @Rule public Act...
Nirav Jadeja
1

votes
0

answer
35

Views

Testsuite name property in instrumentation tests result xml

I have a test suite in Android Studio that contains 3 test classes. @RunWith(Suite.class) @Suite.SuiteClasses({ TestClass1.class, TestClass2.class, TestClass3.class }) public class MyTestSuite { } When I run that test suite via gradle (./gradlew connectedAndroidDevices), I get a result.xml generat...
Carsten Hagemann
1

votes
1

answer
331

Views

Idling Resource not working in second activity in android

I have two Activities A and B. I am running a background thread for 500ms and update a TextView. Once the TextView is updated, I click on the TextView to go to B Activity. In Activity B I have another background thread which is running for 500ms and update a TextView in the B Activity. I am testing...
XoXo
1

votes
1

answer
194

Views

Firebase test lab showing unexpected test failures

I've started using Firebase Test Lab recently with espresso. All the test cases pass on my local device but when it comes to testing devices present on google cloud, some test cases fail with exceptions like 'NoMatchingViewException'. I've tried increasing the wait time before the test runs and the...
Abhimanyu Kaushal
1

votes
0

answer
88

Views

Network of Travis CI Android Emulator

I'd like to run an Android test on Travis CI but seems like the emulator does not connect to the network. Does Travis CI's Android Emulator support using the network? If so, how to configure .travis.yml to enable this feature? My app uses Firebase Cloud Messaging, which will retrieve a token when th...
PaoYa Chien
1

votes
1

answer
19

Views

Sign library before running Junit Android

I'm developing unit test using JUnit 4 on Android studio, but I need to sign the library before running tests to each function of the library to be accepted on my device. I'm trying the following: build.gradle android { signingConfigs { config { keyAlias 'xxxxx' keyPassword 'xxxxx' storePassword 'xx...
Juliano Oliveira
1

votes
0

answer
64

Views

Setting mock location in Android is innaccurate (only half the distance from the last location)

For a UI test, I'm trying to set a mock location. My app is location aware. I'm trying to test that logic in the app. The first location is set correctly. However, the second location is often inaccurate. Most of the time, the second location ends up being the midway point between the first and seco...
Thomas Fischer
1

votes
0

answer
227

Views

Espresso Testing 'Process Crashed' immediately when using ProGuard

I've got a rather large project for which I've written a test suite. When running the tests on a build that is not minified, the tests run fine. Once I set minifyEnabled to true on the buildType I'm using, the tests immediately fail with the following message: Started running tests Test running fai...
LukeWaggoner
1

votes
1

answer
162

Views

Save Android Monkey random run to script format for later replay

Is there a way to save the random run of Android Monkey into a script with the proper format to later replay it by running: adb shell monkey -p -f script_file 1 EDIT: I know there is a seed flag (-s), but that's not what I want. I have to be able to work with the generated script before feeding it...
FlyingPumba
1

votes
0

answer
48

Views

Mock a singleton method call from constructor

I want to mock the singleton class method, which was called from the constructor. class client { client(String s1, Strings s2, Context ctx) { getInstance().init(ctx); } ConfigurationManage getInstance() { return ConfigurationManager.getInstance(); } } How can i mock the getInstance() when this funct...
Vji
1

votes
0

answer
165

Views

Firebase Test Lab Instrumentation Test Fails At Google Signin

I implemented an app that connects to Google Calendar API to read calendar event of a user. i've been trying to test my application using the Firebase Android Instrumentation Test feature. The features that doesn't require a Login such as home screen were tested and passed just fine. I have not impl...
user3645709
1

votes
2

answer
314

Views

Share test classes between modules

I would like to be able to have common test code in a library module of my android projects, so that the different apps in the project can use them. The problem is, apps cannot import classes from /src/androidTest/java, and if I move that at code into src\main, it would have to move dependencies fro...
Anthony
1

votes
0

answer
154

Views

Test image is loaded by Picasso with Espresso

I'm developing an android application and i'm trying to test one screen that shows a list of elements. The list is implemented using a RecyclerView and each item has a name (TextView) and an image (ImageView). For testing first element name, i use the next code: private static int ANY_ELEMENT_POSIT...
1

votes
0

answer
128

Views

Activity clean up in AndroidTest with Cucmber and RxJava

I observe a weird stack trace at the end of my cucumber test. I base my test on the cucumber-jvm android example. I do some async process in a @Then method with RxJava2. Without async process all is fine. The test is a sucess but something happened during the @After cucumber method. It seems that...
colin aygalinc
1

votes
1

answer
981

Views

How rollback to the previous version (from working to beta version) in google play console?

I created my application and uploaded it into beta testing in google play console. After some tests, I updated it to the working version. But now I want to cancel the working version (which is available to everyone) and post a new beta. How can i do this? I hope you will help.
Bohdan Martynov
1

votes
0

answer
46

Views

Testing PopUpMenu with Robolectric

I have an Image on click of which I display a PopUpMenu. I am not getting any way to test that particular pop up menu that is being displayed. I have two buttons 1) Edit , 2) Delete and what I want to test is the click of the Delete and the edit. Any help is welcome.
Gaurav A Dubey
1

votes
0

answer
165

Views

How to restart Android app (/app state) within Espresso test?

I'm testing login page - specifically 'Autologin' checkbox, so that user being logged-in once, will be automatically logged-in upon reopening the app (by default user should login from scratch). How can I simulate this behaviour? Is restarting an app is the only way? Can I reset an app somehow to in...
Shurov
1

votes
0

answer
149

Views

Illegal connection pointer running Robolectric tests with ContentResolver

I want to test a class that manages data and uses a custom ContentProvider, with Robolectric. I've made a test class with two tests that use a ShadowContentResolver to set some data in the ContentProvider. These tests work perfectly on their own, but if I test the whole class, I get an error in the...
dumazy
1

votes
1

answer
406

Views

Android packageName test with kotlin 'kotlin.jvm.internal.Intrinsics' error

I'm looking to get started with connected tests on an existing android java app using kotlin tests. The test passed using the base provided ExampleInstrumentedTest.java but converting it to kotlin gave the following error. java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/In...
mononz
1

votes
0

answer
46

Views

Ignored Espresso test cases not shown in HTML Test Report

When running Espresso test cases with gradle and check the HTML test report I can only see PASS and FAIL test cases but not IGNORED ones. Doing some troubleshooting, I force it to have an IGNORED test case using Assume, and a PASS one: @Test public void test_1() { Assume.assumeTrue('No WiFi connecti...
Alberto Jiménez
1

votes
0

answer
81

Views

Testing BaseActivity

I have a BaseActivity, which has Dagger behavior inside: abstract class BaseActivity : DaggerAppCompatActivity(), HasSupportFragmentInjector { @Inject lateinit var fragmentDispatchingAndroidInjector: DispatchingAndroidInjector override fun onCreate(savedInstanceState: Bundle?, persistentState: Per...
BestPractice2Go
1

votes
0

answer
61

Views

Why doesn't Espresso wait for actual view conditions?

Why doesn't Google Espresso actually wait for View conditions to become true and instead only checks IdlingResources and AsyncTaks to become idle and assert s the conditions? It would be so much easier and more reliable if instead of waiting for the latter Espresso would just continue checking until...
Lina
1

votes
0

answer
27

Views

Using androidTestImplementation class in Activity

Its just an experiment but can I use AppiumDriver class that belong to dependency declared as androidTestImplementation 'io.appium:java-client:6.1.0' in the activity and not in InstrumentedTest class of Android?
Sushant Somani
1

votes
1

answer
71

Views

Why does JBehave test run within Android Studio unit test folder, but fail within integration test folder?

I'm new to JBehave and trying to get a simple test running within Android Studio. I've started with a new project (specifying 'Add no activity'), modified the app/build.gradle file to include the dependency for JBehave, and added 3 files: app/stories/example.story, IntegrationTestStoryRunner.java an...
lennymski
1

votes
0

answer
131

Views

Android API 28 and Roboelectric 4.0-alpha-3 throwing Realm lib error

On switching the project to API 28 (compileSdk and targetSdk) Robolectric warned that it does not support API 28. On then updating the Robolectric dependency from v3.6.1 to: testImplementation 'org.robolectric:robolectric:4.0-alpha-3' Running tests then produces this error: java.lang.UnsatisfiedLink...
Ollie C
1

votes
0

answer
29

Views

Android testing: Prevent async task to fire in Activity onCreate

I'm trying to write some tests for Android for the first time. I have an app that calls server (via AsyncTask) in OnCreate function to get some settings. But I don't want to call server when running my instrumented tests. Currently I have achieved this by setting some static variable in @BeforeClas...
Brontes
1

votes
0

answer
25

Views

androidTest folder and apk not creating for product flavor android instrumentation testing

I am facing a problem when testing the android instrumentation test using product flavor. Here is details of my scenario: My project src folder look: Here sp3 is my flavor. and androidTest is the instrumentation test folder which contains PresenterTest class. Here is my gradle flavor: flavorDimensio...
0xalihn
1

votes
0

answer
60

Views

How to fill adapter with mock data in unit test?

In my application I get some data from server and show into RecyslerView. I can get data and fill adapter and show into RecyclerView, but I want write Test for this with Mockito Test and fill adapter for show into RecyclerView. I use this link for json : https://api.learn2crack.com/android/jsonandr...
Dear User
1

votes
0

answer
45

Views

Grant SYSTEM_ALERT_WINDOW permission for Android Instrumented tests

I'm trying to grant the SYSTEM_ALERT_WINDOW permission for Instrumented tests with a GrantPermissionRule (from androidx.test.rule.GrantPermissionRule package) as follow: @get:Rule var permissionRule: GrantPermissionRule = GrantPermissionRule.grant( android.Manifest.permission.SYSTEM_ALERT_WINDOW, an...
Jojo44
1

votes
2

answer
214

Views

Android studio - androidTest folder is missing

I'm working on automation test using Espresso. The folder in which Instrumentation test classes can be written is missing Screenshot of the project I tried by adding android{ sourceSets{ main { java.srcDirs = ['src/main/java'] } test { java.srcDirs = ['src/test/java'] } androidTest { java.srcDir...
Suhas
1

votes
0

answer
65

Views

Testing ListPreference

I'm trying to test android preferences, and I'm a bit confused as to how to achieve that result. Here is my preference I want to test that when I change the number in the displayed ListPreference, the SharedPreference is actually changed. Right now, the code works, I'm just blocking on the testing...
jeremyb
1

votes
0

answer
230

Views

Unable to Set Up Instrumentation Testing Android Studio

I have a project that doesn't't have instrumentations tests set up, so I am following Android's own instructions but, as usual, it's garbage and doesn't work... here are the instructions After adding useLibrary 'android.test.runner' useLibrary 'android.test.base' useLibrary 'android.test.mock' in t...
BlondeSwan

View additional questions