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
5
votes
1 answer

ResourceNotFoundException for resource in library gradle module during instrumentation test

During an instrumentation test, my app is throwing the following error. This error is not thrown in my non-test builds. android.content.res.Resources$NotFoundException: String resource ID #0x7f030002 I have two gradle modules :app…
5
votes
1 answer

AndroidTest Failed while running from command line :app:connectedDebugAndroidTest

I'm using android spring RestTemplate for making REST service calls on my app. I added android Instrumentation test which includes mocking the REST service calls. All my test are running fine while running from android studio, but the test failed to…
5
votes
0 answers

ClassNotFoundException but I can find this class in classes.dex

I have two projects: one is my android library project (com.my.lib), one is a test project to test the library project (com.my.lib.test). In the test project, there is a test class which tests the corresponding class in library project which…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
5
votes
1 answer

Android Studio Junit tests package org.junit does not exist

I'm trying to implement a test class in Android Studio to make some test on a DBAdapter. Since I need to run the test on my mobile phone in order to use the database, I have created an Instrumentation Unit Test (cause I've tried to do it just with a…
5
votes
2 answers

Is it possible to perform end to end testing with Espresso in Android?

In the past week I was searching to find helpful information regard end to end testing on Android. Although I found UI Automator, it didn't catch my eyes. I'm working on an application that its happy path contains 6 activities. I want to create my…
Hesam
  • 52,260
  • 74
  • 224
  • 365
5
votes
4 answers

Set applicationApk and instrumentationApk for Spoon Gradle Plugin

I'd like to set .apk files that will be used to run my tests with SpoonGradlePlugin. There are available properties I can set programatically from gradle…
F1sher
  • 7,140
  • 11
  • 48
  • 85
5
votes
2 answers

UiDevice.getInstance(getInstrumentation()) Crashes (as Null object reference) when Launching the Instrumentation using startInstrumentation()

Android SDK : 22 (L) UiAutomator Version : 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1' On a Button Click I am trying to Access Instrumentation from an Android Application using Boolean start = false; start =…
5
votes
0 answers

Android unit tests - How to test a service using ServiceTestCase

I'm having issues creating unit tests for a Service in Android Studio. I have set up my project to perform unit tests and have successfully set up tests for a different (non-Service) class. I can run those tests and have them pass. This is the code…
4
votes
0 answers

Android instrumentation tests throwing SecurityException

I'm developing a small set of instrumented tests using JUnit and Espresso to automate the testing process of my activities and fragments, but I'm having some crashes in some devices. The test suite runs fine on the Pixel 6 with API 31 and on the…
4
votes
1 answer

Android Instrumented tests with KodeIn

We have an Android app that is using compose for the view layer and we are using Kodein for all of our dependency injections. I have a BaseApplication class which is DIAware: class BaseApplication : Application(), DIAware { override val di: DI =…
Maurycy
  • 3,911
  • 8
  • 36
  • 44
4
votes
1 answer

How to overcome this build error when trying to run jetpack compose instrumentation tests

I've followed the jetpack compose navigation codelab. Everything was going well until it came to testing the NavHost in step 7. When trying to run the tests, I get the following error and stack trace : FAILURE: Build failed with an exception. *…
4
votes
0 answers

Android-JUnit5 No instrumentation registered! when getting context

I know this is "common" error but I am trying to make a JUnit5 Android Room test working. I found out that JUnit5 does not support the instrumentation test (or google does not support JUnit 5 I should say) but I discovered that…
rXp
  • 617
  • 2
  • 12
  • 25
4
votes
1 answer

Android, run regular app in instrumentation mode (adb + debug only)

I'd like to run an Android app in a way that it can access InstrumentationRegistry.getInstrumentation() during the runtime. This is only for debug builds and installing the app through ADB is sufficient. Because I don't want to use the…
4
votes
0 answers

Android's R file in androidTest is not generating when applicationIdSuffix is used

I've created an Android project from scratch, with package name com.example.myapplication I've a strings.xml file in the main package (app module), with a String called yyy. I've another strings.xml file in the androidTest package, with a String…
Josue
  • 725
  • 2
  • 10
  • 22
4
votes
2 answers

Espresso android - IllegalStateException: UiAutomationService android.accessibilityservice.IAccessibilityServiceClient already registered

Getting IllegalStateException exception randomly running on AWS, for the below defined Rule @Rule public GrantPermissionRule permissionRule = GrantPermissionRule.grant() Here is the exception trace INSTRUMENTATION_STATUS:…