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
13
votes
3 answers

Calabash-android: attach to running app

I have calabash-android set up working perfectly with a default scenario (using cucumber to run tests or calabash-android console to enter REPL mode). However, under some scenarios, it turns out to be pretty useful to be able to attach to an app…
Anton
  • 2,483
  • 2
  • 23
  • 35
12
votes
2 answers

ActivityTestRule is deprecated on android test

This is a scope of my instrumented test: ... import androidx.test.rule.ActivityTestRule @RunWith(AndroidJUnit4::class) @LargeTest class InstrumentDialogFragmentTest { @get:Rule val activityRule =…
12
votes
2 answers

Android Test new Service in Test Package

I wanted to test a class in a framework that starts different services based on an intent. However, I am having issues create the TestService inside the androidTest/ when connected android test is being run. The getService method returns…
Dillon
  • 364
  • 5
  • 18
12
votes
1 answer

connectedAndroidTest on multiple emulators

Background I want to run my Android Instrumented tests on Jenkins on different emulators. Say I have 100 tests and 4 emulators, I want to run 25 tests on each. I perform ./gradlew connectedDebugAndroidTest in Jenkins Pipeline's parallel for 4…
azizbekian
  • 60,783
  • 13
  • 169
  • 249
12
votes
4 answers

Getting Instrumentation run failed due to 'java.lang.NullPointerException'

I am trying to write Unit test cases for Activities in my app by extending the test class with ActivityUnitTestCase. I could successfully run the test cases earlier but now I'm always getting the exception while running them. Even though I'm pretty…
11
votes
2 answers

Test run failed to complete. Instrumentation run failed due to Process crashed. with debugger inside a module

I'm starting to implement instrumentation testing for my company to increase our code quality and speed of deployment. I'm rewriting a module of our application and I'm trying to implement TDD principles. My code does not work at the moment and I…
Shindra
  • 133
  • 6
11
votes
2 answers

Drag & Drop Espresso

Is it possible to perform drag & drop action via Espresso? I need to move one view down (in straight line) in order to accept some conditions in my automation test.
F1sher
  • 7,140
  • 11
  • 48
  • 85
11
votes
2 answers

Espresso Instrumentation Tests - how to uninstall or delete the app after the test

I setup Espresso instrumentation framework to run my Android Functional Automation tests. For every test, I want to login to the app and delete the app after I finish the test. So, I setup something like below: public class FirstSampleTest extends…
user5599934
  • 311
  • 5
  • 13
11
votes
2 answers

How to change activities title in attach()

I want to run a parameterized Instrumentation Test featuring different locales to run the same test with all supported languages. The observed behavior is that the activity will have the localized title of the first test run also for every following…
11
votes
1 answer

Is there a way to write a unit test for a target API

I am in the process of writing Android instrumented tests in an area were Robolectric custom shadows fall short. Ideally, we want to write code that is flexible across all versions of the Android SDK however I am in an edge case situation where I…
Mark Lapasa
  • 1,644
  • 4
  • 19
  • 37
11
votes
2 answers

Creating notification from InstrumentationTestCase

I want to test from a unit test whether a notification is able to play a custom sound from assets. The test is not meant to verify anything, I wrote it as a quick way of demonstrating a feature without cluttering the main app code. So In the test…
Mister Smith
  • 27,417
  • 21
  • 110
  • 193
11
votes
1 answer

Wait until view become visible with IdleResource

I am writing Instrumentation tests with usage of Espresso 2.2. Flow I want to test: radioButton clicked by test onClick launches request to API after every time different time I receive response positive response triggers interface method that is…
F1sher
  • 7,140
  • 11
  • 48
  • 85
10
votes
2 answers

Running Instrumented Test with arguments using command prompt

I've an InstrumentedTest @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext(String groupName) { Context appContext = InstrumentationRegistry.getTargetContext(); UiDevice…
Sushant Somani
  • 1,450
  • 3
  • 13
  • 31
10
votes
1 answer

Testing RxJava2 using Espresso and getting a null pointer exception when suscribeOn

Android Studio 3.0 Beta2 I am testing getting a list for an endpoint using RxJava2. The app works fine when running normally. However, when I test using espresso I get a null pointer exception when I try and subscribeOn(scheduler). For the…
10
votes
2 answers

How can I use @FlakyTest annotation now?

I try to run flaky test with espresso framework (and with Junit4) on Android Studio. I want to set how many times it should to repeat. Before I can use @FlakyTest(tolerance=5) // (5 is number for repeat, for example) But this annotation was…
1 2
3
35 36