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

Android instrumentation tests for library module coverage

I inherited an android project to setup code coverage for. Not having done much for android and almost as little in gradle, I embarked on a quest to find a helpful tutorial. As surprises go, the first few tutorials were very helpful and I was able…
10
votes
2 answers

Code coverage in android studio 1.2 for instrumented tests

I have been trying to use the new code coverage feature in Android Studio 1.2. There seems to be no documentation for the feature, but so far I figured out to add testCoverageEnabled true to the debug flavor of my Gradle file. Still I can only…
9
votes
0 answers

How can you disable the V/InstrumentationResultParser output when running Instrumentation Tests

I recently upgraded to Android Studio 3.2.1/com.android.tools.build:gradle:3.2.1, and noticed that when I run Instrumentation Tests there is a lot of new output that clogs up the logs I like to view. Here's a small preview: 07:38:28…
9
votes
3 answers

Android Test cases not working in debug mode

I am not able to debug android Instrumentation test cases (using espresso & UiAutomator) But earlier test cases the debugging was working fine but with recent update it is not working anymore. It gets always struck up at instantiating unit test I…
9
votes
2 answers

annotationProcessor + androidTest + dagger2

For instrumented tests, I have a TestApplication that creates a TestComponent, but the file is not generated anymore (Error:/xxx/TestApplication.java:16: The import.xxx.DaggerTestApplicationComponent cannot be resolved). I'm not able to identify the…
9
votes
1 answer

Parameterized Instrumented Tests for Android

The answer to AndroidJUnit4 and Parameterized tests links to a Google example for using @RunWith(Parameterized.class). However, this is a simple unit test. How do I run parameterized instrumented tests?
8
votes
1 answer

Example for replacement for InstrumentationRegistry.getContext()

With AndroidX the InstrumentationRegistry is now deprecated. The documentation states This method is deprecated. In most scenarios, getApplicationContext() should be used instead of the instrumentation test context. If you do need access to the…
DoDo
  • 2,248
  • 2
  • 22
  • 34
8
votes
0 answers

ActivityScenario.launch looking for some cached jar

I am running android instrumentation tests and I have the following code: lateinit var scenario: ActivityScenario @Before fun before(){ scenario = ActivityScenario.launch(MainActivity::class.java) } The tests themselves, run…
Lena Bru
  • 13,521
  • 11
  • 61
  • 126
8
votes
1 answer

Android Instrumented tests configuration problem

I have some Espresso tests which are in the androidTest directory of Android Studio. When I bring cursor over the green triangle (see below) to run the test the Studio shows "Run Test" instead of "Run verifySomething" and proceeds to run the test as…
8
votes
2 answers

Measuring performance using Android instrumentation test

My goal was to write automatic performance test for Android CPU intensive code using an instrumental test (AndroidJUnitRunner). I was very surprised to find that the test results are not reliable, to simulate CPU intensive code, I want to test, I…
8
votes
8 answers

Cannot resolve symbol AndroidJUnit4

I'm trying to add loginfacebook for my app. But when I added a repository that is need in doing this. It caused an error. The AndroidJUnit4 cannot resolve now. ExampleInstrumentedTest.java package com.example.user.enyatravelbataan; import…
8
votes
0 answers

How not to run a particular test when executing connectedAndroidTest?

It takes long to execute some of our instrumented tests. So I'd like not to run them when I run all the other instrumented tests with gradle connectedAndroidTest. Why don't I annotate those tests with @Ignore? Because I'd like to run them later…
Maksim Dmitriev
  • 5,985
  • 12
  • 73
  • 138
8
votes
2 answers

Instrumentation run failed due to 'android.content.res.Resources$NotFoundException'

I try to run tests with espresso 2.2.1 in Android Studio 1.5.1. When I run LoginActivityTest I get this error: "android.content.res.Resources$NotFoundException" caused when LoginActivity calls MyService.java and MyService needs a integer resources…
8
votes
2 answers

Instrumentation run failed due to 'Process crashed.' after long tests execution

I have about 700 tests to execute. When I run them all, there raised a crash "Instrumentation run failed due to 'Process crashed.'" Check device logcat for details. Test running failed: Instrumentation run failed due to 'Process…
8
votes
1 answer

Sharing resources across unit tests and instrumentation tests in Android

Now that Google has added experimental unit test support, how might one go about sharing resources across both unit tests and instrumentation test? For example, say I have a TestUtils.java class that I want accessible in both my unit tests and my…