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

Run all unit tests in Android Studio

I have this project in Android Studio : I wish to run all unit tests in all project with one click. How i can do it ?
Kevin ABRIOUX
  • 16,507
  • 12
  • 93
  • 99
87
votes
14 answers

AndroidX : No instrumentation registered! Must run under a registering instrumentation

I'm trying to run a local unit test that depends on the context, and was following this guide: https://developer.android.com/training/testing/unit-testing/local-unit-tests#kotlin and I set up my project like this (following this link :…
72
votes
9 answers

Error: The apk for your currently selected variant (Unknown output) is not signed. Please specify a signing configuration for this variant (debug)

After upgrading to Android Studio Arctic Fox (2020.3.1) Canary 9. I cannot run my tests. It pops up the Edit Configurations window to show Error: The app for your currently selected variant (Unknown output) is not signed. Please specify a signing…
71
votes
6 answers

The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin

I updated the AndroidStudio to version 3.1 Clean Project... and build failed The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something? However, the 3.0.1 version of AndroidStudio does not have…
36
votes
4 answers

How to grant permissions to android instrumented tests?

I have an application that reads SMSs. The app works fine when debugging but when testing it using android instrumented test it throws the following error java.lang.SecurityException: Permission Denial: reading…
31
votes
3 answers

Android Studio Instrumentation testing build variant

So I am trying to write instrumentation tests using a custom build variant, mock. In this build variant I mocked up my classes and server. When I try using the mock build myself it works fine, but I can't seem to use my mock build for testing.…
30
votes
1 answer

Can I get the instrumentation test to kill and restart the app process?

I need to test a use case where the application starts from a clean state - i.e. the process has not been running before the test starts. From what I see from logcat, all instrumentation tests run under one single process instance/session, so the…
Nilzor
  • 18,082
  • 22
  • 100
  • 167
29
votes
7 answers

Android: Instrumentation run failed due to 'java.lang.ClassNotFoundException': No tests found

I try to run a instrumentation test via "gradlew connectedAndroidTest". I get following error: Tests on GT-I9305 - 4.3 failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException' com.android.builder.testing.ConnectedDevice >…
27
votes
2 answers

Cannot resolve ActivityTestRule after upgrading dependencies. Unable to import ActivityTestRule

I have written instrumentation tests which was working fine, but now getting error cannot resolve ActivityTestRule error after upgrading dependencies to androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation…
27
votes
2 answers

A way to share code between multiple android test modules

I want to achieve something like this: [ComponentTestsModule] com.android.test [FunctionalTestsModule] com.android.test both depends on -> [TestLibraryModule] ? which depends on -> [AppModule] com.android.application Is there any way to do it…
27
votes
2 answers

What is touch mode and why is it important for the ActivityTestRule class?

The ActivityTestRule class takes in an initialTouchMode parameter in its constructor. This is not explained in the class reference (or anywhere online) except as follows: initialTouchMode - true if the Activity should be placed into "touch mode"…
26
votes
1 answer

What is the difference between AndroidJUnitRunner and AndroidJunit4?

I am a newbie to the Android testing world and the samples for Unit tests mention the use of AndroidJunit4 runner. I have stumbled upon another runner called AndroidJUnitRunner. Now, I saw the docs for both the classes and at one glance, it seems…
Manish Kumar Sharma
  • 12,982
  • 9
  • 58
  • 105
26
votes
2 answers

Create DummyActivity inside androidTest folder for testing

I have created a dummy activity inside androidTest folder and declared that activity in AndroidManifest file in androidTest folder. My basic intention is to test a reusable fragment by putting it into a dummy activity with a framelayout…
25
votes
2 answers

connectedAndroidTest how to run specific tests

I am a QA with a start up company. My Developer setup Instrumentation tests in the Android Project. He also setup the Jenkins Jobs to run these tests in CI env. This is the command given in "Tasks" field in Jenkins job under Build --> Invoke Gradle…
jellyBeans
  • 293
  • 2
  • 4
  • 12
22
votes
6 answers

Android instrumented test no tests found

I am new to Android instrumented unit tests. I have a simple test that looks like this. This is in instrumented tests; before I really write an actual instrumented test, I just want to test a simple…
Serban Stoenescu
  • 3,136
  • 3
  • 22
  • 41
1
2 3
35 36