Questions tagged [android-jetpack-compose-testing]
43 questions
0
votes
1 answer
Android. How to test composable function?
I have composable function winch just transform one object to another (state). Here is my code:
@Composable
fun Walpaper.toMaterialState(): MaterialState {
return MaterialState(
price = if (isVip) vipPrice else price,
number =…

testivanivan
- 967
- 13
- 36
0
votes
0 answers
Testing Location API on Firebase Test Lab
We have recently started expanding our UI testing suite and have started to incorporate some tests that involve Google's FusedLocationProviderClient.
In particular one of our tests involves showing a different carousel when the user is within 30km…

Barry Irvine
- 13,858
- 3
- 25
- 36
0
votes
0 answers
Android UI test for Compose HorizontalPager scrollToPage
I'm using HorizontalPager which shows a Skip option to scroll to last page.
val pagerState = rememberPagerState()
val coroutineScope = rememberCoroutineScope()
ConstraintView {
val (skipText, pager) = createRefs()
....
Text(
…

Kavin Prabhu
- 2,307
- 2
- 17
- 36
0
votes
1 answer
How to Run Compose UI tests multiple times in a row locally?
I have a bunch of UI tests in the codebase with which I am currently working that are marked as @FlakyTest. Usually the fail on the CI but very rarely they also fail locally.
I am looking for a way to run one single test multiple times in a row to…

Gianluca Veschi
- 1,239
- 1
- 14
- 20
0
votes
1 answer
Testing a Composable with assertTextEquals() fails with IllegalStateException
I am testing a simple TextField composable and I am using onNodeWithContentDescription() to locate this TextField which I have applied semantics on its modifier.
TextField(
modifier = Modifier
.fillMaxWidth()
…

Tonnie
- 4,865
- 3
- 34
- 50
0
votes
1 answer
assert button color is MaterialTheme.colors.primary in composable
I have a simple button. It's color set is set based on condition and I want to test correct color is applied from MaterialTheme but test fails saying @Compos
@Composable
fun Btn(shopState: Int) {
//set color based on the state now, default being…

Hobo
- 43
- 6
0
votes
0 answers
Android. How to access pdf document from android test?
I have create PdfViewer with compose. Now I need to write android tests for my component. My PdfViewer retrieves uri.
The problem is that in the test I need to somehow get uri on a pdf document. Is it possible to do this?
And if there is no pdf…

testivanivan
- 967
- 13
- 36
0
votes
2 answers
I Can't figure out how to write a Test to pass a Composable Test in Android
I took a Codelab Lunch-tray App it had no Tests so I tried to create these tests to practice. I tried to create testcases for it based on another codelab Codelab Cupcake
The way these 2 projects differ is that on the second codelab(Lunch-tray) the…

Lixo
- 71
- 11
0
votes
0 answers
waitForIdle vs awaitIdle in Compose Testing
What is the difference between waitForIdle() and awaitIdle() in android's compose testing API?
Does anyone have examples of when they would use one over the other?

mars8
- 770
- 1
- 11
- 25
0
votes
1 answer
composeTestRule checking that atleast 1 item exists
I have a list which has 2 different items. However, if the user gets close to the end of the list then the 2 same items are added again and again to create an infinite scrolling feel.
I've created a test to basically verify that the item exists like…

KTOV
- 559
- 3
- 14
- 39
0
votes
1 answer
Compose android testing fails: Idling resource timed out
I'm trying to write the test for my composes. So I have a test class put in AndroidTest just like this:
@HiltAndroidTest
@UninstallModules(AuthenticationModule::class, AppModule::class)
class AuthenticationScreenTest {
@get:Rule(order = 0)
…

Mohammad Derakhshan
- 1,262
- 11
- 33
0
votes
1 answer
SemanticsNodeInteraction.captureToImage() returns slightly different result depending on device/composable
My goal is to test colors of my composables. For some reason assertion below fails on specific device/composable (e.g. Composable1 passes on Device1 and on Emulator1, Composable2 fails on Device1, but passes on Emulator1). The color difference is…

Nazar Dunets
- 175
- 2
- 10
0
votes
1 answer
How can I check if a radio button is selected in Jetpack Compose UI tests?
Does anybody know how to check, which radio button is selected in Android UI tests for Jetpack Compose created UI?
I made a radio button group via the attached code, but I don't know how to identify which one is selected by the UI…

AName
- 1