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
0
votes
0 answers

android test web service in junit and mockito without instrumentation test

I have this instrumented test which works fine: @Test public void testWebService() { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); AuthService authService = new…
aurelianr
  • 538
  • 2
  • 12
  • 35
0
votes
0 answers

How to assert if a particular value exists in a list view in UIInstrumentation test

I am trying to do instrumentation test. I am doing it on youtube.My initial tests are running true but failing in assertion. What I am trying to achieve is open youtube search something and assert by checking if it exists in the result. So I search…
Pritish
  • 1,284
  • 1
  • 19
  • 42
0
votes
1 answer

Engagement Time Calculation When App Is In Background

How to calculate engagement time whenever my app is in background. User engagement (firebase automatically collected event) calculate periodically, while the app is in the foreground. But how to add the time in user engagement when my app is in back…
0
votes
1 answer

Context getColor in activity and AndroidJunit4 return different result. Why?

I'm getting color (i.e. R.color.my_white is FFFFFFFF ) from my resource as below ContextCompat.getColor(getContext(), R.color.my_white) And when I perform AndroidJUnit4 testing, I also get the same color. ContextCompat.getColor(getContext(),…
Elye
  • 53,639
  • 54
  • 212
  • 474
0
votes
0 answers

Jacoco Code Coverage Showing Testing Report not Coverage report

After including Jacoco plugin and enable the testCoverageEnabled = true in app.gradle. I added AndroidJacocoTestRunner java file After running CreateDebugCoverageReport it gives the Report but not the Code coverageTest Report image source.
0
votes
1 answer

How can I wirite JUnit test to ensure Arraylist records are correct?

I have a method which prepare a list(ArrayList) based on the result of a query.But how can I write test cases to ensure the number and type of records in the list are correct? Thanks in advance.
0
votes
1 answer

Running bash script using gradle android studio before androidTests

I have android project using java which uses a nodejs server hosted on heruko. What I want is to run a local server before androidTest(instrument test), I have tried writing batch(bash*) file and running my server as an external tool. That doesn't…
0
votes
0 answers

Android Instrumentation Test without target-package

I have a android library that dependence on logcat. I want to have an instrumentation test for this library. However, the instrumentation require me to specify a target-apk to instrument. But, I don't need/have one. So, what is the proper way to…
user1947415
  • 933
  • 4
  • 14
  • 31
0
votes
1 answer

How can I run both '@SmallTest' and '@MediumTest' and not '@LargeTest'?

Details: I want to be able to run all @SmallTest and @MediumTest tests while ignoring @LargeTest tests. It looks like Android ADB instrumentation commands support negation. For example, you can negate annotation like notAnnotation but I do not see a…
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
0
votes
2 answers

Set device orientation in Android Instrumentation Test on AWS device farm

I'm uploading my Android apk and instrumentationTest apk to aws device farm, but it keeps running my app in portait. In my app I have set the orientation to landscape in the manifest with…
0
votes
1 answer

Interprocess or adb communication with AndroidJUnit

I want to know, does any way exist to communicate with system during instrumentation test execution. For example: I have a phone with IR port on onboard & I can work with it through private SDK, also I can tune it with my application. In my…
once2go
  • 1,452
  • 1
  • 13
  • 21
0
votes
0 answers

Is there any way to add a method or code snippet in Android main project which only compiles with test project?

I have one method in android app main project, which I want to compile only when I run Instrumented Unit Tests. For example:- Class MyActivity extends Activity { // some usual methods.... // my method which I want to compile only when…
0
votes
0 answers

Realm instrumentation tests observables

Apologies for the long question, I have tried to reduce the problem to as small as I could think of while keeping relevant information in. I have written 2 realm repositories, both of which follow the same pattern but just deal with different realm…
Thomas Cook
  • 4,371
  • 2
  • 25
  • 42
0
votes
1 answer

Testing searchview in android - Instrumentation testing

I have a searchview in my action bar, where I can press on search button in action bar, write some text, then click on the search button on softkeyboard and then it should display the list of results in recycler view. I want to test this to see if…
Sushil
  • 8,250
  • 3
  • 39
  • 71
0
votes
1 answer

Android espresso multiple test paths

How do I have an if/else path in my tests for example when a certain dialog is present I dismiss it and continue vs when it's not present I continue nonetheless
ir2pid
  • 5,604
  • 12
  • 63
  • 107