Are there any recommended approaches for integrati...
# compose-ios
j
Are there any recommended approaches for integration testing iOS app built using Compose Multiplatform?
e
j
that allows you test to test say particular screen.....was more wondering about full integration testing
e
I have some "more complex" tests in Alkaa. I created a wrapper to start Koin, allowing navigating through the whole application and validating app flows with DB, etc. Something like that? https://github.com/igorescodro/alkaa/tree/main/shared/src/commonTest/kotlin/com/escodro/alkaa
j
thanks, I'll take a look at that
❤️ 1
https://docs.maestro.dev/ was also recommended....but still trying to figure out if/how it can work with CMP apps
e
I tried Maestro but it didn't work at all with my app. Maestro recognized everything as a single node, instead of nodes for each component. I don't know if this was addressed on more recent Compose versions or if I was missing some accessibility flag on my app to separate them.
j
e
That's interesting! Thanks for sharing.
j
@Guilherme Delgado sorry to tag you directly but just curious if you got further with this? I tried just now with simple XCUITest (which Maestro seemingly uses under the hood on iOS) but didn't work (running on simulator with code added as per https://github.com/mobile-dev-inc/Maestro/issues/1549#issuecomment-2225724812)
Actually having a bit more luck with maestro than using XCUITest directly
g
Hello @John O'Reilly no problem at all, I’m always available to help 🙂 . I didn’t go any further since the
configure = { accessibilitySyncOptions = AccessibilitySyncOptions.Always(null) },
worked for me. I’ve tried again and it works with Maestro and also with Accessibility Inspector. I had to change the code to include those settings:
Copy code
@OptIn(ExperimentalComposeApi::class)
fun MainViewController() = ComposeUIViewController(
    configure = { accessibilitySyncOptions = AccessibilitySyncOptions.Always(null) },
    content = { App() }
)
j
I added that as well here and seem to be getting further using maestro....only thing is I couldn't do following it seems in CMP
Copy code
.semantics { testTagsAsResourceId = true }
            .testTag("EmailTextField"),
g
Didn’t try with the XCUITest though
j
testTagsAsResourceId
seems to be android specific for some reason
Were you able to add tags like this in CMP code to use as part of test?
g
Let me try 🙂
j
I think for button you can just use label for example to select but trying to for example select edit field and enter text in it
Maestro studio just shows these as options without that
g
I’m getting unresolved
testTagsAsResourceId = true
🤔 any ideia?
j
yeah, that's same as here.....seems to be android specific
👍 1
g
Screenshot 2025-02-19 at 11.25.36.png
Copy code
OutlinedTextField(
    input, onValueChange = { input = it },
    modifier = Modifier.testTag("EmailTextField")
)
would you consider this a success?
Screenshot 2025-02-19 at 11.27.08.png
j
ah, thought I tried that but didn't see tag....let me try again
g
It’s strange that the accessibility inspector perceives this as a button rather than an input. 🤔
Android Simulator the same with “Select to Speak” but when using “Talk Back” it’s correct
j
strange....still not seeing that tag in inspector....will keep digging
👍 1
g
this sample is running
compose-multiplatform = "1.7.0"
j
Using 1.7.3 here
will try 1.7.0 just to see if that is the difference
g
I’ve bumped to yours to check it also 😊
Works too with 1.7.3
j
nice, thanks for checking....something else must be up here
g
Funny thing, with
1.8.0-alpha03
the
import androidx.compose.ui.platform.AccessibilitySyncOptions
gets unresolved…
`AccessibilitySyncOptions` removed. The accessibility tree is built on demand
j
hmm, interesting
g
Yup you don’t need to add those settings 🙌 in the ComposeUIViewController but:
Can you spot the difference?
When attaching the Accessibility Inspector to the macOS it resolves as an input text, when attached to the simulator, resolves as button 🤷‍♂️
(I don’t know if it’s related with the compose version, I’ll check that too. I’m going to run on real device to see how it behaves)
j
this seems to be very much an evolving area with CMP
1
g
on physical device the experience is the same as in the simulator
It sees the input element, but does not resolve the type as Text Field
Screenshot 2025-02-19 at 12.24.52.png
I’m going to open an issue about it 😉
👍 1
j
btw did you have to do anything particular to get this working on Android (again using CMP).....just tried now and
testTag
values I added (which were visible in iOS case) aren't showing up in maestro studio etc?
g
Didn’t check that yesterday, but I’ve the same problem, on Android I can’t see the `testTag`:
on iOS - bounding box shifted on 1.8.0-alpha03 -, appears
j
ok, thanks....do you remember if you had to setup anything particular for Android....around accessibility etc, to get that working?
g
UI Check doesn’t spot it also (don’t know if it is supposed to)
I actually couldn’t get that to work with CMP. 😓
maybe this could be related (not only for iOS): https://youtrack.jetbrains.com/issue/CMP-5656/Support-TextField2-on-iOS
j
so, seeing tag now if I add this for Android in say
MainActivity
(where CMP code is wrapped)
Copy code
setComposeView {
            Column(
                modifier = Modifier.semantics { this.testTagsAsResourceId = true }
            ) {
but only for
Copy code
.semantics {
                    testTag = "EmailTextField"
                }
doesn't work with just
.testTag("EmailTextField")
(at least in terms of visibility in maestro studio)
ah, but
tapOn
works when using just
testTag
....seems to line up somewhat with what you noticed above
g
Screenshot 2025-02-20 at 13.05.58.png
yes 😊
I’ve tried with 1.8.0-alpha03 and just needed to add this:
Copy code
setContent {
    Box(modifier = Modifier.semantics { testTagsAsResourceId = true }
    ) {
        App()
    }
}
like you said
The:
Copy code
OutlinedTextField(
    input, onValueChange = { input = it },
    modifier = Modifier.semantics(properties = {
        testTag = "EmailTextField"
    })
)
remain the same.
j
btw also running in to following when using Maestro on iOS https://kotlinlang.slack.com/archives/C0346LWVBJ4/p1740058860625179
👍 1
m
another way to e2e testing using natural language https://www.mobileboost.io/
g
FYI: The release notes states:
Accessible text input
In Compose Multiplatform 1.8.0-beta01 we’ve introduced support for text fields’ accessibility traits. When a text input field comes into focus, it is now marked as editable, ensuring proper accessibility-state representation.
You can now also use accessible text input in UI testing.
But the TextField problem reported still happens with
1.8.0-beta-01
.