Framework for Android instrumented testing to interact with UI components.
Questions tagged [instrumented-test]
116 questions
3
votes
3 answers
What would run ExampleUnitTest but not find ExampleInstrumentedTest?
Android Studio: 3.6.1
Gradle: gradle-5.6.4-all
I am ready to test my app and found that Android Studio produces example unit and instrumented tests. So, I right-click ExampleUnitTest, select Run and it runs just fine. However, when I do this for…

Jeff
- 431
- 4
- 16
3
votes
1 answer
Can no longer run individual instrumented tests in Android Studio
For two months or so now I haven't been able to run individual UI tests in Android Studio. Right clicking on the test name and then run just give me the error No tests were found. If I right click on the class name and then click run…

odiggity
- 1,496
- 16
- 29
3
votes
4 answers
Android Instrumented testing asserting if an activity is started
I am developing an Android application using Kotlin programming language. I am adding instrumentation tests into my application. Now I am trying to test if an activity is started after some delay.
This is my activity code.
class MainActivity :…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
2
votes
0 answers
Android instrument test in gitlab CI/CD runner, installed on a virtual machine
I'm struggling to run an android emulator in a GitLab CICD job.
Right now we have Proxmox virtualization on bare metal which hosts some VMs. One of the VMs is a GitLab runner. The runner uses the docker executor for CICD jobs. So I need to run an…

Ali Golmirzaei
- 61
- 7
2
votes
1 answer
./gradlew connectedVariantNameAndroidTest failed
At Android studio's terminal key in "./gradlew connectedVariantNameAndroidTest".
Result with following error message:
Task :app:connectedDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task…

Squall Huang
- 647
- 9
- 20
2
votes
1 answer
Why instrumented room test get error FOREIGN KEY constraint failed
I don't understand this error, I have two entities Task and Project, one task is assign to one project (see code below).
But when I want test to add a task, I have this error:
android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint…

mabdelouahad
- 93
- 6
2
votes
2 answers
ComponentActivity ClassNotFoundException when trying to setup Instrumented tests, with Android Compose and Hilt
I'm setting up my first instrumented unit-test and getting an obscure crash in logcat.
The emulator starts and immediately crashes when the app tries to open and the unit test doesn't even run because the application wasn't in the right…

David Aleksanyan
- 2,953
- 4
- 29
- 39
2
votes
1 answer
Dagger 2 injection in Android instrumentation tests
I'm trying to use Dagger 2 for DI in my Android instrumentation tests. It works perfectly fine for Classes/Activities/Fragments in the main application component, but my test component seems to be missing some bindings I can't find. Any ideas on how…

Daniel Schröder
- 547
- 4
- 18
2
votes
0 answers
Android UI testing - ActivityScenarioRule is significantly slower then ActivityScenario
I'm getting into Android UI testing, and I learnt two ways to start up activities: ActivityScenario in each test, and ActivityScenarioRule once, annotated with @Rule.
At first I used ActivityScenario, with success. Each test took around 2-4 second…

Gtomika
- 845
- 7
- 24
2
votes
1 answer
Getting failed in providing HiltTestApplication as a dependency in my test module
I have followed this guide and trying to run instrumented test with HILT.But its getting failed in providing HiltTestApplication as a dependency in my test module.
Below is my module…

Android Developer
- 9,157
- 18
- 82
- 139
2
votes
2 answers
android jetpack navigation instrumented test fail on back navigation
I've created a simple, two fragment example app using jetpack Navigation component (androidx.navigation). First fragment navigates to second one, which overrides backbutton behavior with OnBackPressedDispatcher.
activity layout

Piotr Śmietana
- 393
- 2
- 19
2
votes
1 answer
Basic testing NavigationController in Android
I'm currently new to testing, so I decided to start off with some basic stuff.
I handle all my navigations from a DrawerLayout that is connected to an Activity.
So for my testing I launch an ActivityScenarioRule, create a testNavController object…

Barrufet
- 495
- 1
- 11
- 33
2
votes
2 answers
Android Kotlin Espresso asserting intended activity in the unit test is throwing error
I am developing an Android application. I am adding instrumented tests to my application and testing if an activity is launched using Espresso. But I am getting error in asserting that an activity is launched using the Espresso test framework.
I…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
2
votes
0 answers
Get SurfaceTexture in android instrumented tests
As in title, I am looking way to get or create SurfaceTexture, which I can pass to CaptureSession(in Camera2 API). Is there a chance to create programatically virtual TextureView, then attach it to virtual WindowManager, and then get Surface, and…

404pio
- 1,080
- 1
- 12
- 32
2
votes
2 answers
Having trouble doing instrumented testing with AndroidX LiveData and mock view models
Ever since porting over a project to Android Jetpack library ("AndroidX"), I am having trouble getting instrumented tests involving a mock view model and LiveData manipulation to work.
I built a relatively simple app exhibiting the same error here:…

Spheniscine
- 491
- 4
- 8