Framework for Android instrumented testing to interact with UI components.
Questions tagged [instrumented-test]
116 questions
1
vote
0 answers
How to inject mocked ViewModel into Fragment during Instrumented tests with Android Hilt?
I am having a hard time to get my instrumented tests on Android.
Goal: Inject a mocked ViewModel during a Fragment Instrumented test.
Context:
My ViewModel is built using the Hilt Jetpack integrations and the @ViewModelInject annotation as the…

Guilhermevrs
- 2,094
- 15
- 15
1
vote
2 answers
Robolectric test fails when trying to inflate layout that has a TextInputLayout
Android Studio 4.0.1
Robolectric 4.3.1
I am writing a robolectric test and the test will fail with a error below. And seems to be related to the TextInputLayout that can't be inflated. If I remove the TextInputLayout the test will pass ok.
This is…

ant2009
- 27,094
- 154
- 411
- 609
1
vote
1 answer
Simulate No Internet Connection/Slow Internet Connection in Android Instrumented Test
I am writing a library that checks the the connection of the android device continuously and gives a callback when the device gets connected, disconnected or the internet connection becomes slow.
https://github.com/muddassir235/connection_checker
I…

Muddassir Ahmed
- 518
- 4
- 19
1
vote
1 answer
unable to use custom buildType - Active build variant "debug" does not have a test artifact
I took a look around and see some questions very similar to mine but it does appear to have the same solution I have in place which does not resolve the problem.
When I try to run a method test I receive an error in the footer of android studio that…

DevinM
- 1,112
- 1
- 12
- 29
1
vote
1 answer
Android Kotlin (Instrumented) test, asserting that the ImageButton has the right resource is not working
I am developing an Android application using Kotlin. I am writing instrumented tests for my application. Now, I am having a problem testing ImageButton because it is not working as expected. I want to test that an ImageButton view is set with the…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
1
vote
1 answer
How to test the background of textview if it's right drawable set xml resource in Android Espresso in Kotlin programming language
I am developing an Android application using Kotlin. I am adding instrumented tests to my application. I am having a problem testing the background of textview if it's right drawable set in XML resource.
I am setting the background of the text view…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
1
vote
1 answer
Android Kotlin instrumented test testing if an activity is ended/ finished after calling finish() starting another activity
I am developing an Android app using Kotlin. I am adding instrumented tests in my project. Now, I am struggling with testing if an activity is not opened after launching another activity. This is my scenario.
I have MainActivity that starts…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
1
vote
1 answer
Is there a way to stop launching activity in Android instrumented tests Kotlin (ActivityTestRule)
I am developing an Android application using Kotlin. I am adding instrumented tests into my project. Now, I am looking for a way to enable/disable the logic for launching activity because it can make my test behaving in unexpected ways.
This is my…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
1
vote
0 answers
Instrumented test: could not find dependencies
I'm trying to launch a simple instrumented test on my project, but something gone wrong. This is my simple test class (the default one):
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
//…

giozh
- 9,868
- 30
- 102
- 183
1
vote
0 answers
Screenrecord doesn't work when invoked from code
I'm trying to get videos of failed tests on my CI server.
The goal is to start the screen capture on every test, and then when it fails save the video somewhere, and when it passes, remove the video. The CI server would pick up the files using…

Benoit Duffez
- 11,839
- 12
- 77
- 125
1
vote
1 answer
Android Instrumented unit test on project library
I inherited an Android Project composed by the main app and a Library . My goal is to test the whole project, so I started from the Library : first i use JUnit to test some classes/method, writing my test undeer app/src/test/java (unit test) of my…

Lubron
- 35
- 2
- 15
1
vote
0 answers
where to put the android Instrumented test json file
In Android Instrumented test, it needs to read from some moc json files to get the test case's json data.
Find some post suggest to put in the app's asset folder. Would that the moc json file be packaged with the app's resource?
And see the Android…

lannyf
- 9,865
- 12
- 70
- 152
0
votes
0 answers
Why is it so slow to start instrumented test in Android Studio?
I have the latest version on Android studio (Giraffe)
And I have built a very small app from the project wizard (the "empty activity" template)
When I run the app several times consecutively, it starts in less than a second.
If I change the code,…

Laurent D.
- 449
- 4
- 19
0
votes
0 answers
How to write Instrumented Tests for Jetbrains Compose Multiplatform Windows App
I have an app built with Jetbrains Compose Multiplatform
I develop it on MacOS, but I generate an .msi installer which runs the App on Windows machine.
Is there any way to write automated UI tests / Instrumented Tests, which can run both on Windows…

SVK
- 676
- 1
- 5
- 17
0
votes
1 answer
App is uninstalled after playing instrumented tests since migration to Giraffe
I have used Flamingo for some time, and after playing an Espresso test, the app was still installed.
Then I upgraded to Giraffe, and now, after playing an Espresso test, the app is uninstalled.
I did not changed my project, just upgraded Android…

Laurent D.
- 449
- 4
- 19