Questions tagged [android-jetpack-compose-testing]

43 questions
2
votes
0 answers

Android, Compose. How to correctly test animated scroll in compose?

I'm trying to test accompanist PagerState. The author has already added tests (https://github.com/google/accompanist/blob/main/pager/src/sharedTest/kotlin/com/google/accompanist/pager/PagerStateUnitTest.kt), however he uses scrollToPage, but I need…
2
votes
1 answer

How to create a Page/Screen Object Model in Jetpack Compose Testing

For basic testing, if I create a test class like below, it works fine. class MyComposeTest { @get:Rule val composeTestRule = createAndroidComposeRule() @Test fun myTest() { …
2
votes
0 answers

How to select an image from the gallery in a jetpack compose test

I have a composable that opens the gallery and selects an image to display to the user. I'd like to test this functionality but composeTestRule doesn't have access to the gallery. I would like to mock out the intent like what is done with espresso…
2
votes
1 answer

Compose : advanceTimeBy doesn't work with animation

I've two Boxes and one Button. Clicking on the Button would toggle a flag and it triggers an AnimatedVisibility animation on these Boxes. Code @Composable fun TestBox() { Box( modifier = Modifier.fillMaxSize(), contentAlignment =…
1
vote
1 answer

Writing tests for Composable screen with repeated items in Jetpack Compose

I am currently working on a Composable screen in a Jetpack Compose-based Android application. The screen displays a list of products using card-style views. Each card is tagged with a product code for testing purposes. I've encountered a scenario…
1
vote
0 answers

How to write compose UI test to verify background color of a button

I'm new into JetPackCompose and trying to test the background color of a button but I don't get the expected result. I'm asserting that the button's color with the expected color…
1
vote
0 answers

Testing in hybrid android project

I have an android application which have navigation through xml and the screen from which is I am navigating is written in compose. I want to test the click. If I use Espresso onView, it is unable to find the button because the button is written in…
1
vote
0 answers

Compose Test rule Ui Testing

I am trying to test the compose layout using composeTestRule, I am trying to write a custom matcher to get the following sibling node. Is there any way we can write our own custom matcher to select the next/following sibling node? Tried to use the…
1
vote
0 answers

Do I need to use Espresso for my compose app?

I cannot figure out which testing API to use for my instrumented tests on my app built using compose. In the Android testing docs it mentions 4 different APIs (espresso, compose, UI Automator, Roboelectric). My intuition is that I would like to use…
mars8
  • 770
  • 1
  • 11
  • 25
1
vote
1 answer

How to simulate a swipe gesture on a Card in a Composable Test?

I have an app that has a composable MyCard(). I am testing the app in myTest() and would like to simulate a swipeRight gesture on the card. When I use performTouchInput { swipeRight() } nothing happens. The UI does not update and card stays in the…
1
vote
0 answers

How to test infinite loop Horizontal pager content in Android Jetpack Compose

I am trying to write UI test cases to validate screen content. Composable screen has below content Text Button Infinite Loop Horizontal pager to display texts I am getting below error when i try with below test case @Test fun testMyScreen() { …
1
vote
0 answers

Compose Test is Flaky

My some view that starts from an activity shows an alert dialog when pressing the back button using the BackHandler. @Composable fun PostEditContent( title: String, uiState: BasePostEditUiState ) { var enabledBackHandler by remember {…
1
vote
1 answer

How to dismiss soft keyboard in jetpack compose test?

I'm writing tests for a jetpack compose screen that has a text field on it. In my test I want to enter some text into the field, then dismiss the soft keyboard, then click a button that was hidden beneath the soft keyboard. I cannot find a way to…
Alex Egli
  • 1,884
  • 2
  • 24
  • 43
1
vote
0 answers

Why compose ui testing's IdlingResource is blocking the main thread?

I've written a "minimal" AS project to replicate my the problem I'm facing. Here's the gh link. I'm trying to write an end-to-end ui test in my compose-only project. The test covers a simple sign-in -> sync data -> go to main view use case. Here's…
0
votes
0 answers

Why can't I access to ComposeTestRule when UI testing with xml and compose screen hybrid

Android Compose UI test: I am getting this error when I tried to use composeTestRule to access compose node. This only happens when my app finishes login sync and app brings up the homescreen. My app has a takeover screen over the homescreen after…