Questions tagged [android-jetpack-compose-testing]
43 questions
16
votes
2 answers
Compose UI testing - How do I assert a text color?
I'm trying to test a Text that on my component I can print it in different colors, so on my test I'm verifying it gets the expected color. I was looking for a method to return the color but I did not find any.
From now I'm asserting that the text is…

Skizo-ozᴉʞS ツ
- 19,464
- 18
- 81
- 148
14
votes
0 answers
How to get code coverage for Compose UI tests?
I'm now somewhat familiar with UI testing within Jetpack Compose thanks to the extensive Android Documentation, but I can't make Android Studio to run Compose tests with coverage. We are currently using Jacoco as coverage tool to generate the…

Franbede
- 418
- 1
- 6
- 11
9
votes
2 answers
Test recorder for jetpack compose
I want to record a UI test in my jetpack compose project, just like record an Espresso test.
I want to follow thees steps:
start recording
open the application
click on the objects(buttons, etc...)
finish recording
get generated kotlin codes…

milad mosavie
- 183
- 7
8
votes
0 answers
How UI test Jetpack Compose using Firebase Test Lab?
For testing compose layout we have a default library.
To run Firebase Test Lab (FTL) it says you need Espresso or UI Automator frameworks.
But I'm not sure if this is outdated or not.
Putting my APKs (that use jetpack compose and the compose testing…

Canato
- 3,598
- 5
- 33
- 57
8
votes
3 answers
Jetpack Compose back button press in automation test
What is the recommended way to trigger a back button press in a jetpack compose test (running on a real device)?
I'm trying:
@get:Rule()
val composeTestRule = createAndroidComposeRule(MyActivity::class.java)
@Test
fun test() {
// Here would be…

Oliver Metz
- 2,712
- 2
- 20
- 32
6
votes
1 answer
how to test android compose mutableStateOf like flow Turbine
I following the new google guide and end with this to represent the state in viewmodel like tis
var uiState: AccountSettingUiState by
mutableStateOf(AccountSettingUiState.Initial)
private set
then I have this function
fun…

ASA
- 371
- 1
- 3
- 11
6
votes
2 answers
IllegalStateException: FocusRequester is not initialized during Jetpack Compose testing
I have a screen with TextFields. I need the first TextField to be automatically focused when the screen is displayed.
Minified Example code
@Composable
fun ScreenView(
data: ScreenViewData,
) {
val focusManager = LocalFocusManager.current
…

Abhimanyu
- 11,351
- 7
- 51
- 121
6
votes
2 answers
Printing Compose Semantics Tree to the Log
I am following Testing in Jetpack Compose Codelab but I am unable to print the Semantics tree using the printToLog function on a node. I am using this code inside the androidTest package.
import androidx.compose.ui.test.printToLog
...
…

Tonnie
- 4,865
- 3
- 34
- 50
4
votes
2 answers
how to assert that text not contains specific characters in android jetpack compose testing?
I'm trying to write some test cases for my compose functions.
I have an outlined Text field with a maximum value of 16 characters.
So I want to test this feature. Here is the test:
@Test
fun checkMaxTaxCodeLength_16Character() {
val…

Mohammad Derakhshan
- 1,262
- 11
- 33
4
votes
1 answer
How to read the Semantic values of a Jetpack Compose TextField through UI tests?
I am new to Jetpack Compose testing and trying to figure out how to access the values of an OutlinedTextField to perform Instrumentation tests on them:
I can't figure out the syntax to access and check some of the values in the SemanticsNode of the…

Booger
- 18,579
- 7
- 55
- 72
3
votes
4 answers
Compose Android Test Lazy Column Not Detect All The Children
I have a LazyColumn inside a Composable, I want to check every item in that LazyColumn is exist.
This is my composable:
(Note: Actually in my real case the each item has different component, I just make it similar for simplify the…

galihif
- 310
- 1
- 8
3
votes
3 answers
How to iterate over an element (node) list on Android Jetpack Compose UI Tests?
I'm implementing some instrumented tests using the Jetpack Compose testing library. I'm not too familiar with Kotlin / Android development yet, but I have years of experience with Selenium and other testing libraries, so I'm missing some basic…

luis
- 31
- 2
3
votes
3 answers
How to unit test if an image was loaded using Coil + Compose
I'm loading an image using Coil for Compose like below.
@Composable
fun SvgImageSample() {
val painter = rememberAsyncImagePainter(
model = ImageRequest.Builder(LocalContext.current)
.decoderFactory(SvgDecoder.Factory())
…

nglauber
- 18,674
- 6
- 70
- 75
3
votes
1 answer
Is it possible to assert that a node is scrollable in jetpack compose testing
Is it possible to assert that a jetpack compose node is scrollable when performing tests?
class MyTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun givenEnoughItems_thenAssertListIsScrollable() {
…

Chris
- 4,662
- 2
- 19
- 27
2
votes
0 answers
Android JetPack Compose Testing. How do I check if the Toast message appears?
I tried to do this but it doesn't work.
onNodeWithTag(TestTag.OPEN_DRAWER_BUTTON).performClick()
onNodeWithTag(TestTag.SYNCHRONIZE_BUTTON).performClick()
onNodeWithText(activity.getString(R.string.success_update)).assertExists()
I get…

CalmPerson
- 57
- 5