Questions tagged [android-instrumentation]

Base class for implementing application instrumentation code.

Base class for implementing application instrumentation code.

When running with instrumentation turned on, this class will be instantiated for you before any of the application code, allowing you to monitor all of the interaction the system has with the application. An Instrumentation implementation is described to the system through an AndroidManifest.xml's <instrumentation> tag.

Reference: http://developer.android.com/reference/android/app/Instrumentation.html

526 questions
6
votes
1 answer

Android: How to stop instrumentation test after first failure

We have a suite of Android instrumentation tests which we run from CL via ./gradlew app:connectedDebugAndroidTest If there is a failing test we basically have to wait for all of them to complete before the HTML report is generated. What we would…
tir38
  • 9,810
  • 10
  • 64
  • 107
6
votes
0 answers

Get permission to access USB device (host mode) in Android Instrumentation test

The usual way of accessing a USB device in host mode on Android is as follows: UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE); PendingIntent pi =…
6
votes
0 answers

How to do category based testing for connectedAndroidTest?

I have around 25 tests on my android tests package. I have some tests that I to run during integration and some tests that run as normal instrumentation tests. I am trying to call the integration tests using Gradle tasks but it seems impossible for…
6
votes
0 answers

Android crash reported with Instrumentation

I have Crashlytics enabled on my app and I got a weird crash which I have a problem explaining for a few devices. The crash log contains android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126). Does that mean that this crash…
6
votes
0 answers

Android instrumented tests code coverage report that includes all app modules

I have an Android project with multiple library modules. At the application module I have some instrumentation tests that test the main functionalities of the app and I want to record the code coverage when running those tests. When running the…
6
votes
3 answers

Instrumentation test fail randomly with multidexing enabled

In my android app I have multidexing enabled. The app runs fine on emulators. I am using robotium for testing the app. But when I execute instrumentation test cases, sometimes the test passes, but mostly they also fail after system reboot. There is…
6
votes
2 answers

Jenkins and Running AndroidJUnitRunner Instrumentation Tests

I've got an Android application which I'm trying to set up with Jenkins. I've got it booting up an emulator using the Android Emulator Plugin, and building the project with a gradle script, but I can't get it to run a simple test I wrote utilizing…
6
votes
2 answers

onTouchEvent by code via Instrumentation

I want to accomplish following: I have two buttons. When first button is pressed, it will fire onTouchEvent on second button, thus pressing second button. Here is the excerpt of code that fires event: int test1[] = new…
nurgasemetey
  • 752
  • 3
  • 15
  • 39
6
votes
4 answers

How to regain Access on a Activity after sending it to background

With Espresso I try to test sending an Activity to background, with the Home button and then getting it up in the foreground again to make some checks: @EspressoTest public void test() { onSomeView().check(matches(isDisplayed())); …
joecks
  • 4,539
  • 37
  • 48
5
votes
3 answers

Testing fragment: I keep getting java.lang.RuntimeException: android.view.InflateException

I was following this codelab about Material Components and after finishing it I thought I should practice writing some instrumentation tests. The app works fine. But I keep getting this error when I run any of the tests: …
5
votes
0 answers

Getting permission denied exception when writting to instrumented context internal folder

I've created a function that copies a file from assets to the internal path in my instrumented tests. fun copyFileFromAssetsToInternal(context: Context, fis: FileInputStream) { File(context.filesDir, file).outputStream().use { fos -> …
Cruces
  • 3,029
  • 1
  • 26
  • 55
5
votes
0 answers

How to run instrumentation test with AndroidX on application as well as library module?

I have an android project which contains 2 modules. Android Library Module Android Demo App Module for Library I have setup required Test dependency, Gradle configuration same for both the project. When I run a test from demo app it runs without…
5
votes
2 answers

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…
Shurov
  • 400
  • 1
  • 9
  • 20
5
votes
1 answer

Instrumentation test cases for InputMethodService

I have extended the InputMethodService class to create my a custom IME. However, I am struggling to write valid Instrumentation test cases to verify the behavior. Previously the Service, could be tested using ServiceTestCase. But…
5
votes
2 answers

Where to put Android Instumentation test data

I want to use large files (> 2 GB zip archives as well as video files) in my instrumentation tests to test file loading from SD card / internal storage. How can I write these instrumentation tests and equip them with the files they need? For other…
PhilLab
  • 4,777
  • 1
  • 25
  • 77