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

Android - Empty test suite (AbstractMethodError)

Here are the configurations in the build.gradle file: testCompile 'junit:junit:4.12' androidTestCompile('com.android.support:multidex-instrumentation:1.0.1') { exclude group: 'com.android.support', module: 'multidex' } androidTestCompile…
Romain R.
  • 920
  • 12
  • 21
0
votes
0 answers

Mocking method before activity is created?

I am using Espresso and Mockito for testing an Activity. Is it possible to mock a method before an activity is created. public class MyActivity extends Activity { public int i; @Override protected void onCreate(final Bundle savedInstanceState) { …
azzits
  • 345
  • 2
  • 3
  • 10
0
votes
1 answer

Triggering key event without EditText from KeyboardView

The standard way of triggering key event could look like this: onView(allOf(withId(R.id.edit_text), isDisplayed())).perform(ViewActions.pressKey(KeyEvent.KEYCODE_0)); What to do if there is no target view( edit_text ) but there is custom Keyboard…
0
votes
0 answers

Robolectric Error:Converting Bytecode to dex

I am encountering the error of converting Bytecode to dex with the following trace. Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or…
Ashik Vetrivelu
  • 1,021
  • 1
  • 9
  • 24
0
votes
1 answer

espresso to wait for activity onDestroy

The test is: in ActivityA, a button click starts ActivityB and closes ActivityA. How to test that ActivityA has been destroyed? I've created an IdlingResource to check isFinishing() or isDestroyed(), and also monitored a boolean in a custom…
mbmc
  • 5,024
  • 5
  • 25
  • 53
0
votes
1 answer

Android Espresso: Run test cases on Second activity

How to interact with the webactivity which launched from another activity ? My test case is Launching my login activity, filling the user credentials on edit texts and performing click() action.…
0
votes
1 answer

Local Unit Test Android

Can someone show me a working code to do a unit test on this code? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); } Please show me using local…
Tesla_PH
  • 3
  • 4
0
votes
1 answer

Espress - Accessing nth child element of linear layout

In espresso i am trying to access 3rd child element of linear layout. see attached screenshot. i tried some matcher, but not get it working.
0
votes
1 answer

Looking for a way to write collected in-memory-logs in an android app just before the app closes

For the purpose of profiling, I instrumented my android application so that it collects some log at the beginnings and ends of all functions. I do so by calling a public static method called keepLog(String log) at method boundaries. I also wrote…
Meysam Feghhi
  • 945
  • 2
  • 11
  • 23
0
votes
1 answer

Android test: instrumentation and with maven build

I cannot find a tutorial about how to setup Android instrumentation test with Maven build on internet. So, I tried myself with some explorations. I have several questions & problems: I found pieces of information here and there, but get more…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
0
votes
1 answer

Android Espresso Turn OFF Cellular Data on Android Emulator through Runtime() not working

I am writing instrumentation test for a scenario where data is not available on android emulator (api 16 and api 23). I tried the following code to disable data, @Test public void disconnectData() throws IOException { String line; Process p…
Prabin Timsina
  • 2,131
  • 3
  • 16
  • 27
0
votes
0 answers

cAT uninstalling app and device not found

I am running instrumentation tests through ADB over WiFi and I frequently run into device not found after running a percentage of total tests. I execute the tests using ./gradlew cAT and I am not sure of two things that are happening when executing…
Anil Gorthy
  • 869
  • 3
  • 13
  • 30
0
votes
0 answers

getting null pointer exception for android database testcase

I want to write testcase for android database module. Below is the code I am writing. @RunWith(AndroidJUnit4.class) @SmallTest public class DatabaseTest { private SQLiteDatabase mDatabase; private HeaterDataSource…
Karanbeer Kaur
  • 365
  • 4
  • 14
0
votes
1 answer

How to test if a method has been invoked in Android Instrumentation Tests?

@Test public void testWhenUserNameAndPasswordAreEnteredShouldAttemptLogin() throws Exception { LoginView loginView = Mockito.mock(LoginView.class); Mockito.when(loginView.getUserName()).thenReturn("George"); …
Kaloyan Roussev
  • 14,515
  • 21
  • 98
  • 180
0
votes
1 answer

Android InstrumentationTestCase on custom view using resource, not found

I have a custom view that creates Views dynamically. public class MyCustomView extends LinearLayout { ... private View foo() { View view = new View(getContext()); view.setBackgroundColor(ContextCompat.getColor(getContext(),…
Distraction
  • 410
  • 1
  • 3
  • 13